Skip to content

Commit

Permalink
Actually Fixed: Out of Bounds Potential Read on Pattern Not Found in …
Browse files Browse the repository at this point in the history
…Vectorised Impl
  • Loading branch information
Sewer56 committed Aug 23, 2023
1 parent 8a41729 commit 2871fe6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Reloaded.Memory.Sigscan/Scanner_AVX2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static PatternScanResult FindPatternAvx2(byte* data, int dataLength, stri
int matchTableLength = matchTable.Length;

var firstByteVec = Vector256.Create(patternData.Bytes[patternData.LeadingIgnoreCount]);
int searchLength = dataLength - Math.Max(patternData.Bytes.Length >> 5 << 5, AvxRegisterLength); // bitshift rounds down
int searchLength = dataLength - Math.Max((patternData.Bytes.Length + 31) >> 5 << 5, AvxRegisterLength); // shift by 5 == 32

int leadingIgnoreCount = patternData.LeadingIgnoreCount;
ref var pVec = ref patternVectors[0];
Expand Down
2 changes: 1 addition & 1 deletion Reloaded.Memory.Sigscan/Scanner_SSE2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static PatternScanResult FindPatternSse2(byte* data, int dataLength, stri
int matchTableLength = matchTable.Length;

var firstByteVec = Vector128.Create(patternData.Bytes[patternData.LeadingIgnoreCount]);
int searchLength = dataLength - Math.Max(patternData.Bytes.Length >> 4 << 4, SseRegisterLength); // bitshift rounds down
int searchLength = dataLength - Math.Max((patternData.Bytes.Length + 15) >> 4 << 4, SseRegisterLength); // shift by 4 == 16

int leadingIgnoreCount = patternData.LeadingIgnoreCount;
ref var pVec = ref patternVectors[0];
Expand Down

0 comments on commit 2871fe6

Please sign in to comment.