mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Fix a segfault in bsdgrep when parsing the invalid extended regexps "?"
or "+" (these are invalid, because there is no preceding operand). When bsdgrep attempts to emulate GNU grep in discarding and ignoring the invalid ? or + operators, some later logic in tre_compile_fast() goes beyond the end of the buffer, leading to a crash. Fix this by bailing out, and reporting a bad pattern instead. Reported by: Steve Kargl MFC after: 1 week
This commit is contained in:
parent
20136ffc7b
commit
00f060000f
1 changed files with 1 additions and 1 deletions
|
|
@ -621,7 +621,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n,
|
|||
case TRE_CHAR('+'):
|
||||
case TRE_CHAR('?'):
|
||||
if ((cflags & REG_EXTENDED) && (i == 0))
|
||||
continue;
|
||||
goto badpat;
|
||||
else if ((cflags & REG_EXTENDED) ^ !escaped)
|
||||
STORE_CHAR;
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue