From owner-freebsd-bugs@FreeBSD.ORG Thu Oct 9 07:00:13 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C964E106569A for ; Thu, 9 Oct 2008 07:00:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B87558FC12 for ; Thu, 9 Oct 2008 07:00:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m9970D0R048309 for ; Thu, 9 Oct 2008 07:00:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m9970DNZ048308; Thu, 9 Oct 2008 07:00:13 GMT (envelope-from gnats) Date: Thu, 9 Oct 2008 07:00:13 GMT Message-Id: <200810090700.m9970DNZ048308@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Dorr H. Clark" Cc: Subject: Re: gnu/105221: grep(1): `grep -w -F ""` issue X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Dorr H. Clark" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Oct 2008 07:00:13 -0000 The following reply was made to PR gnu/105221; it has been noted by GNATS. From: "Dorr H. Clark" To: bug-followup@FreeBSD.org Cc: freebsd-bugs@FreeBSD.org, martinko Subject: Re: gnu/105221: grep(1): `grep -w -F ""` issue Date: Wed, 8 Oct 2008 23:53:08 -0700 (PDT) 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;