]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Fix stack buffer overflow in `rvermicelliDoubleExecReal()` (#392) develop
authorGabe DiFiore <difioregabe@gmail.com>
Mon, 20 Apr 2026 07:36:16 +0000 (03:36 -0400)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2026 07:36:16 +0000 (10:36 +0300)
Fix stack buffer overflow in rvermicelliDoubleExecReal

Remove unconditional snprintf that writes input buffer length into
fixed 255-byte stack buffer. On inputs >255 bytes, this causes stack
smash detected by FORTIFY_SOURCE. The removed lines were debug
scaffolding that duplicated the DEBUG_PRINTF above them.

Fixes crash on patterns like ".*literal" with buffers >255 bytes.

src/nfa/vermicelli_simd.cpp

index e8210f2cca5659e0d7821ac2ce4149d286331e58..3bea78b95c59d9c967f49d594e1075868a59a642 100644 (file)
@@ -368,9 +368,6 @@ const u8 *rvermicelliDoubleExecReal(char c1, char c2, SuperVector<S> const casem
     assert(buf < buf_end);
     DEBUG_PRINTF("rverm %p len %zu\n", buf, buf_end - buf);
     DEBUG_PRINTF("b %s\n", buf);
-    char s[255];
-    snprintf(s, buf_end - buf + 1, "%s", buf);
-    DEBUG_PRINTF("b %s\n", s);
 
     const u8 *d = buf_end;
     const u8 *rv;