Date: Tue, 4 Apr 2017 17:05:37 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316495 - head/usr.bin/grep/regex Message-ID: <201704041705.v34H5bZ5079394@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704041705.v34H5bZ5079394>