From owner-freebsd-bugs@FreeBSD.ORG Thu Oct 9 06:53:13 2008 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93DAD1065697; Thu, 9 Oct 2008 06:53:13 +0000 (UTC) (envelope-from dclark@engr.scu.edu) Received: from endor.engr.scu.edu (smtp.engr.scu.edu [129.210.16.13]) by mx1.freebsd.org (Postfix) with ESMTP id 62D3C8FC2A; Thu, 9 Oct 2008 06:53:12 +0000 (UTC) (envelope-from dclark@engr.scu.edu) Received: from nova41.dc.engr.scu.edu (nova41.dc.engr.scu.edu [129.210.16.38]) by endor.engr.scu.edu (8.13.6/8.13.6) with ESMTP id m996r9qJ029129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Oct 2008 23:53:11 -0700 Received: from localhost (dclark@localhost) by nova41.dc.engr.scu.edu (8.13.6/8.13.6) with ESMTP id m996r8cB015588; Wed, 8 Oct 2008 23:53:08 -0700 (PDT) X-Authentication-Warning: nova41.dc.engr.scu.edu: dclark owned process doing -bs Date: Wed, 8 Oct 2008 23:53:08 -0700 (PDT) From: "Dorr H. Clark" X-Sender: dclark@nova41.dc.engr.scu.edu To: bug-followup@FreeBSD.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-bugs@FreeBSD.org, martinko Subject: Re: gnu/105221: grep(1): `grep -w -F ""` issue X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Oct 2008 06:53:13 -0000 gnu/105221 The behavior described in 105221 is due to 'grep' looping infinitely within Fexecute() of revision 1.25 of search.c. When used with the combination of '-w' and '-F' and the empty string, 'grep' enters a inescapable "while(1)" block A proposed fix then, is to immediately fail the search for a match when grep is called with this combination of options if the string to match is zero-length (and thus, trivially does not match the non-empty input!). David K Lam Engineer Dorr H. Clark Advisor Graduate School of Engineering Santa Clara University Santa Clara, CA http://www.cse.scu.edu/~dclark/coen_284_FreeBSD/105221.txt --- /usr/src/gnu/usr.bin/grep/search.c 2006-02-19 04:27:39.000000000 +0000 +++ search.c 2008-08-21 00:29:38.000000000 +0000 @@ -959,6 +959,10 @@ } else if (match_words) { + + if(beg[len-1] == eol) + break; + while (1) { int word_match = 0;