From nobody@FreeBSD.org  Mon Nov  6 19:53:13 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2303316A412
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Nov 2006 19:53:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8CC3343D76
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Nov 2006 19:53:12 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id kA6JrCOd007900
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 6 Nov 2006 19:53:12 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id kA6JrCrG007899;
	Mon, 6 Nov 2006 19:53:12 GMT
	(envelope-from nobody)
Message-Id: <200611061953.kA6JrCrG007899@www.freebsd.org>
Date: Mon, 6 Nov 2006 19:53:12 GMT
From: martinko<gamato@users.sourceforge.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: grep(1): `grep -w -F ""` issue
X-Send-Pr-Version: www-3.0

>Number:         105221
>Category:       gnu
>Synopsis:       grep(1): `grep -w -F ""` issue
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 06 20:00:41 GMT 2006
>Closed-Date:    
>Last-Modified:  Thu Oct  9 07:00:11 UTC 2008
>Originator:     martinko
>Release:        FreeBSD 6.2-PRERELEASE
>Organization:
>Environment:
FreeBSD mb-aw1n-bsd 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #0: Sat Sep 23 10:05:07 CEST 2006     root@mb-aw1n-bsd:/usr/obj/usr/src/sys/MB-AW1N  i386
>Description:
after running the following command grep(1) starts eating all available cpu and won't finish:
$ echo qaz | grep -w -F ""
>How-To-Repeat:
just run the following from your shell:
echo qaz | grep -w -F ""
>Fix:

>Release-Note:
>Audit-Trail:

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@freebsd.org, gamato@users.sourceforge.net
Cc:  
Subject: Re: gnu/105221: grep(1): `grep -w -F ""` issue
Date: Sun, 27 Jan 2008 20:58:22 +0000

 It appears this bug was introduced with revision 1.20 of search.c.
 It's still an issue on 7.0-RC1.
 
 --
 Bruce

From: "Dorr H. Clark" <dclark@engr.scu.edu>
To: bug-followup@FreeBSD.org
Cc: freebsd-bugs@FreeBSD.org, martinko <gamato@users.sourceforge.net>
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;
 
 
  
  
 
 
 
 
>Unformatted:
