Skip to content

Commit

Permalink
Fix buffer overrun
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Oct 19, 2023
1 parent d4149d5 commit 22968cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/arch/x86/AVX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ namespace hat::detail {
secondByte = _mm256_set1_epi8(static_cast<int8_t>(*signature[1]));
}

alignas(__m256i) const auto [signatureBytes, signatureMask] = load_signature_256(signature);
__m256i signatureBytes, signatureMask;
if constexpr (veccmp) {
std::tie(signatureBytes, signatureMask) = load_signature_256(signature);
}

begin = next_boundary_align<alignment>(begin);
if (begin >= end) {
Expand Down
6 changes: 5 additions & 1 deletion src/arch/x86/AVX512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ namespace hat::detail {
secondByte = _mm512_set1_epi8(static_cast<int8_t>(*signature[1]));
}

alignas(__m512i) const auto [signatureBytes, signatureMask] = load_signature_512(signature);
__m512i signatureBytes;
uint64_t signatureMask;
if constexpr (veccmp) {
std::tie(signatureBytes, signatureMask) = load_signature_512(signature);
}

begin = next_boundary_align<alignment>(begin);
if (begin >= end) {
Expand Down
5 changes: 4 additions & 1 deletion src/arch/x86/SSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ namespace hat::detail {
secondByte = _mm_set1_epi8(static_cast<int8_t>(*signature[1]));
}

alignas(__m128i) const auto [signatureBytes, signatureMask] = load_signature_128(signature);
__m128i signatureBytes, signatureMask;
if constexpr (veccmp) {
std::tie(signatureBytes, signatureMask) = load_signature_128(signature);
}

begin = next_boundary_align<alignment>(begin);
if (begin >= end) {
Expand Down

0 comments on commit 22968cb

Please sign in to comment.