Fix findPattern logic when pattern is at the end of the data

references #404
This commit is contained in:
Vitaly Cheptsov 2024-10-09 23:36:23 +03:00 committed by GitHub
parent 3441255566
commit 0030ea9481
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -461,7 +461,7 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi
if (patternSize == 0 || dataSize == 0 || dataOff >= dataSize || dataSize - dataOff < patternSize)
return -1;
while (dataOff + patternSize < dataSize) {
while (dataOff + patternSize <= dataSize) {
bool matches = true;
for (UINTN i = 0; i < patternSize; i++) {
if ((data[dataOff + i] & patternMask[i]) != pattern[i]) {