svn commit: r316495 - head/usr.bin/grep/regex
Conrad Meyer
cem at FreeBSD.org
Tue Apr 4 17:05:39 UTC 2017
Author: cem
Date: Tue Apr 4 17:05:37 2017
New Revision: 316495
URL: https://svnweb.freebsd.org/changeset/base/316495
Log:
bsdgrep(1): Fix errors with invalid expressions
Invalid expressions with an ultimate compiled pattern length of 0 (e.g.,
"grep -E {") were not taken into account and caused a segfault while trying
to fill in the good suffix table.
Submitted by: Kyle Evans <kevans91 at ksu.edu>
Reviewed by: me
Differential Revision: https://reviews.freebsd.org/D10113
Modified:
head/usr.bin/grep/regex/tre-fastmatch.c
Modified: head/usr.bin/grep/regex/tre-fastmatch.c
==============================================================================
--- head/usr.bin/grep/regex/tre-fastmatch.c Tue Apr 4 16:54:46 2017 (r316494)
+++ head/usr.bin/grep/regex/tre-fastmatch.c Tue Apr 4 17:05:37 2017 (r316495)
@@ -337,7 +337,7 @@ static int fastcmp(const fastmatch_t *fg
* Fills in the good suffix table for SB/MB strings.
*/
#define FILL_BMGS \
- if (!fg->hasdot) \
+ if (fg->len > 0 && !fg->hasdot) \
{ \
fg->sbmGs = malloc(fg->len * sizeof(int)); \
if (!fg->sbmGs) \
@@ -353,7 +353,7 @@ static int fastcmp(const fastmatch_t *fg
* Fills in the good suffix table for wide strings.
*/
#define FILL_BMGS_WIDE \
- if (!fg->hasdot) \
+ if (fg->wlen > 0 && !fg->hasdot) \
{ \
fg->bmGs = malloc(fg->wlen * sizeof(int)); \
if (!fg->bmGs) \
More information about the svn-src-all
mailing list