Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Aug 2017 00:40:14 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r322558 - stable/11/usr.bin/grep/regex
Message-ID:  <201708160040.v7G0eEN4034109@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Aug 16 00:40:13 2017
New Revision: 322558
URL: https://svnweb.freebsd.org/changeset/base/322558

Log:
  MFC r316495: 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.
  
  Approved by:	emaste (mentor, blanket MFC)

Modified:
  stable/11/usr.bin/grep/regex/tre-fastmatch.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c
==============================================================================
--- stable/11/usr.bin/grep/regex/tre-fastmatch.c	Wed Aug 16 00:23:59 2017	(r322557)
+++ stable/11/usr.bin/grep/regex/tre-fastmatch.c	Wed Aug 16 00:40:13 2017	(r322558)
@@ -337,7 +337,7 @@ static int	fastcmp(const fastmatch_t *fg, const void *
  * 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, const void *
  * 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?201708160040.v7G0eEN4034109>