From owner-svn-src-stable@freebsd.org Wed Aug 16 00:40:15 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CFB2DD912B; Wed, 16 Aug 2017 00:40:15 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E048C66EE3; Wed, 16 Aug 2017 00:40:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7G0eEoM034110; Wed, 16 Aug 2017 00:40:14 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0eEN4034109; Wed, 16 Aug 2017 00:40:14 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160040.v7G0eEN4034109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:40:14 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep/regex X-SVN-Commit-Revision: 322558 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2017 00:40:15 -0000 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) \