From nobody@FreeBSD.org  Fri Oct 19 01:36:01 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id B8895B6F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Oct 2012 01:36:01 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 86A978FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Oct 2012 01:36:01 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9J1a1EJ071848
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Oct 2012 01:36:01 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q9J1a1P8071847;
	Fri, 19 Oct 2012 01:36:01 GMT
	(envelope-from nobody)
Message-Id: <201210190136.q9J1a1P8071847@red.freebsd.org>
Date: Fri, 19 Oct 2012 01:36:01 GMT
From: deeptech71 <deeptech71@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bsdgrep(1) segfaults upon empty patterns and case-insensitive mode
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172865
>Category:       bin
>Synopsis:       bsdgrep(1) segfaults upon empty patterns and case-insensitive mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    markj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 19 01:40:01 UTC 2012
>Closed-Date:    Sun Feb 17 19:56:22 UTC 2013
>Last-Modified:  Sun Feb 17 19:56:22 UTC 2013
>Originator:     deeptech71
>Release:        -CURRENT
>Organization:
>Environment:
FreeBSD  10.0-CURRENT FreeBSD 10.0-CURRENT #0 r240768M: Fri Sep 21 06:58:11 CEST 2012     root@:/usr/obj/usr/src/sys/HQ  i386
>Description:
bsdgrep(1) segfaults when it is given an empty pattern (through pattern-
files or a command-line argument) and is instructed to do case-insensitive
matching.
>How-To-Repeat:
Execute the following command line:
bsdgrep -i ""
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Fri Oct 19 02:53:10 UTC 2012 
Responsible-Changed-Why:  
please run bsdgrep --version and reply to the PR. I can not reproduce. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172865 

From: "deeptech71@gmail.com" <deeptech71@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/172865: bsdgrep(1) segfaults upon empty patterns and
 case-insensitive mode
Date: Fri, 19 Oct 2012 13:12:03 +0200

 bsdgrep --version reports:
 bsdgrep (BSD grep) 2.5.1-FreeBSD
 
 The world is compiled with Clang. I'll rebuild an up-to-date
 kernel&world after the recent compilation errors get fixed, and then
 I'll retry to segfault bsdgrep again.
 
 Meanwhile, a GDB backgrace for ``bsdgrep -i ""'' is:
 #0  0x281e14eb in strlen () from /lib/libc.so.7
 #1  0x280bdc55 in regcomp () from /usr/lib/libgnuregex.so.5
 #2  0x0804b005 in ?? ()
 #3  0x288490a0 in ?? ()
 #4  0x00000000 in ?? ()
 #5  0x0000000a in ?? ()
 #6  0x0000000a in ?? ()
 #7  0x00000000 in ?? ()
 #8  0xbfbfdb54 in ?? ()
 #9  0x2805cc06 in _rtld_get_stack_prot () from /libexec/ld-elf.so.1
 #10 0x2806d000 in ?? ()
 #11 0xbfbfdc50 in ?? ()
 #12 0x00000003 in ?? ()
 #13 0xbfbfdc5c in ?? ()
 #14 0x00000000 in ?? ()
 #15 0x00000001 in ?? ()
 #16 0x00000002 in ?? ()
 #17 0x00000000 in ?? ()
 #18 0xffffffff in ?? ()
 #19 0xbfbfdc50 in ?? ()
 #20 0x00000003 in ?? ()
 #21 0x00000001 in ?? ()
 #22 0x00000000 in ?? ()
 #23 0xbfbfdb8c in ?? ()
 #24 0x00000000 in ?? ()
 #25 0x00000000 in ?? ()
 #26 0x00000000 in ?? ()
 #27 0x00000000 in ?? ()
 #28 0x0805214c in ?? ()
 #29 0x2806a2e0 in ?? () from /libexec/ld-elf.so.1
 #30 0x00000001 in ?? ()
 #31 0x28055823 in r_debug_state () from /libexec/ld-elf.so.1
 #32 0x2806a2ac in ?? () from /libexec/ld-elf.so.1
 #33 0xbfbfdb58 in ?? ()
 #34 0xbfbfdbd4 in ?? ()
 #35 0x2806a2ac in ?? () from /libexec/ld-elf.so.1
 #36 0x2806a2e0 in ?? () from /libexec/ld-elf.so.1
 #37 0x0000127f in ?? ()
 #38 0x281bc54e in atexit () from /lib/libc.so.7
 #39 0x080497fc in ?? ()
 #40 0x00000206 in ?? ()
 #41 0xbfbfdc60 in ?? ()
 #42 0xbfbfdc28 in ?? ()
 #43 0x080497fc in ?? ()
 #44 0x00000003 in ?? ()
 #45 0xbfbfdc50 in ?? ()
 #46 0xbfbfdc60 in ?? ()
 #47 0xbfbfdc4c in ?? ()
 #48 0x00000000 in ?? ()
 #49 0xbfbfdc30 in ?? ()
 #50 0x00000000 in ?? ()
 #51 0xbfbfdc30 in ?? ()
 #52 0xbfbfdc4c in ?? ()
 #53 0x00000000 in ?? ()
 #54 0xbfbfdc48 in ?? ()
 #55 0x08049788 in ?? ()
 Previous frame inner to this frame (corrupt stack?)
Responsible-Changed-From-To: eadler->gabor 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Fri Oct 19 11:52:06 UTC 2012 
Responsible-Changed-Why:  
same version I have; over to maintainer for investigation 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172865 

From: "deeptech71@gmail.com" <deeptech71@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: bin/172865: bsdgrep(1) segfaults upon empty patterns and
 case-insensitive mode
Date: Sat, 20 Oct 2012 03:50:53 +0200

 Confirmed with the latest kernel&world.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/172865: commit references a PR
Date: Sat,  5 Jan 2013 22:04:47 +0000 (UTC)

 Author: markj
 Date: Sat Jan  5 22:04:40 2013
 New Revision: 245075
 URL: http://svnweb.freebsd.org/changeset/base/245075
 
 Log:
   Fix a segfault when bsdgrep -i is given an empty pattern string.
   
   PR:		bin/172865
   Reviewed by:	gabor
   Approved by:	emaste (co-mentor)
   MFC after:	1 week
 
 Modified:
   head/usr.bin/grep/regex/tre-fastmatch.c
 
 Modified: head/usr.bin/grep/regex/tre-fastmatch.c
 ==============================================================================
 --- head/usr.bin/grep/regex/tre-fastmatch.c	Sat Jan  5 21:52:38 2013	(r245074)
 +++ head/usr.bin/grep/regex/tre-fastmatch.c	Sat Jan  5 22:04:40 2013	(r245075)
 @@ -468,7 +468,7 @@ static int	fastcmp(const fastmatch_t *fg
    fg->nosub = (cflags & REG_NOSUB);					\
  									\
    /* Cannot handle REG_ICASE with MB string */				\
 -  if (fg->icase && (TRE_MB_CUR_MAX > 1))				\
 +  if (fg->icase && (TRE_MB_CUR_MAX > 1) && n > 0)			\
      {									\
        DPRINT(("Cannot use fast matcher for MBS with REG_ICASE\n"));	\
        return REG_BADPAT;						\
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: markj 
State-Changed-When: Sat Jan 5 22:16:32 UTC 2013 
State-Changed-Why:  
Patched in r245075, thanks! 


Responsible-Changed-From-To: gabor->markj 
Responsible-Changed-By: markj 
Responsible-Changed-When: Sat Jan 5 22:16:32 UTC 2013 
Responsible-Changed-Why:  
Patched in r245075, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172865 
State-Changed-From-To: patched->closed 
State-Changed-By: markj 
State-Changed-When: Sun Feb 17 19:56:21 UTC 2013 
State-Changed-Why:  
The fix was merged to stable/9. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172865 
>Unformatted:
