]> git.ipfire.org Git - thirdparty/vectorscan.git/commit
shufti-double: fix regressions from #325 (#368) develop
authorByeonguk Jeong <jungbu2855@gmail.com>
Tue, 7 Apr 2026 10:10:31 +0000 (19:10 +0900)
committerGitHub <noreply@github.com>
Tue, 7 Apr 2026 10:10:31 +0000 (13:10 +0300)
commitde317291e9c46f8060719f655920043fabc968ed
treed551a7eaa1df3f23dc75db91dd0d892b918d0033
parent6c1b351656826cbd856e8fe1d5ae19e787d502bc
shufti-double: fix regressions from #325 (#368)

* shufti-double: Fix double shufti's caller

run_accel() passed c_end - 1 to shuftiDoubleExec().
shuftiDoubleExecReal already handles the last-byte boundary internally
via check_last_byte(), so shortening the buffer caused it to miss
valid matches near the end and apply the wildcard check to the wrong
byte. Changed to pass c_end.

Fixes: ca70a3d9beca61b58c6709fead60ec662482d36e ("Fix double shufti's
vector end false positive (#325)")

Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
* shufti-double: Preserve first_char_mask after peel-off

first_char_mask was reset to Ones() after the peel-off block,
discarding carry-over state for cross-boundary pattern detection.
Remove the reset.

Fixes: ca70a3d9beca61b58c6709fead60ec662482d36e ("Fix double shufti's
vector end false positive (#325)")

Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
* shufti-double: Fix check_last_byte() loop condition

loop condition i > 2 missed the final vshr(1), leaving odd-indexed
bytes out of the reduce. Use i >= 2.

Fixes: ca70a3d9beca61b58c6709fead60ec662482d36e ("Fix double shufti's
vector end false positive (#325)")

Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
* shufti-double: Add regression tests for double shufti

Add three tests exercising the double shufti edge cases.

- ExecMatchVectorEdge: Two-byte pair ("ab") spanning the peel-off to
  aligned block boundary is correctly detected. Validates that
  first_char_mask state carries over and is not reset after peel-off.

- ExecNoMatchLastByte: First character of a double-byte pair ('x' from
  "xy") at the last buffer byte does not cause a false positive when
  the second character is absent.

- ExecMatchLastByte: Single-byte pattern ('a') at the last buffer byte
  is detected via check_last_byte's reduce.

Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
---------

Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
src/nfa/accel.c
src/nfa/shufti_simd.hpp
unit/internal/shufti.cpp