emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#17245: closed (GREP BUG: grep -P and binary files)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#17245: closed (GREP BUG: grep -P and binary files)
Date: Mon, 21 Apr 2014 18:04:04 +0000

Your message dated Mon, 21 Apr 2014 11:03:10 -0700
with message-id <address@hidden>
and subject line Re: bug#17245: GREP BUG: grep -P and binary files
has caused the debbugs.gnu.org bug report #17245,
regarding GREP BUG: grep -P and binary files
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
17245: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17245
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: GREP BUG: grep -P and binary files Date: Fri, 11 Apr 2014 16:47:03 -0700 User-agent: Mutt/1.5.21 (2010-09-15)
Hi there -

I recently noticed a bug after upgrading grep and have tracked it
through a few versions now.

I was using grep -P (PCRE grep) in some scripts to grep through
directory of files, and the process would keep aborting with a
segmentation fault.

The last known good version is grep-2.14.  Every version after that has
failed in a slightly different way, making me think this could be a bug
in grep, not in pcre.

I tried compiling greps 2.14 through 2.18 against the latest pcre
library, pcre-8.33.  Here's what happens when i try each version against
a random binary file, attached to this message as test-image.png.  This
file was just one of many that caused the errors, though not every
binary file does.

Below are some results demonstrating what's going wrong.  Note that all
of these seem to work fine with regular grep or with grep -E.  Please
let me know what else i can do to help track this down!

# grep-2.14/src/grep -P '\[.?max' test-image.png
(works, does not match)

# grep-2.15/src/grep -P '\[.?max' test-image.png
Aborted

# grep-2.16/src/grep -P '\[.?max' test-image.png
Binary file test-image.png matches
(erroneous - should not match)

# grep-2.16/src/grep -P '.?max' test-image.png
Segmentation fault

# grep-2.17/src/grep -P '\[.?max' test-image.png
Segmentation fault

# grep-2.18/src/grep -P '\[.?max' test-image.png
Segmentation fault

# grep-2.18/src/grep -P '.?ma' test-image.png
Segmentation fault

# grep-2.18/src/grep -P '.?m' test-image.png
Binary file test-image.png matches

-damon

Attachment: test-image.png
Description: PNG image


--- End Message ---
--- Begin Message --- Subject: Re: bug#17245: GREP BUG: grep -P and binary files Date: Mon, 21 Apr 2014 11:03:10 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
On 04/16/2014 05:13 AM, Norihiro Tanaka wrote:
http://bugs.exim.org/show_bug.cgi?id=1468

Thanks. The response there makes it clear that if grep passes arbitrary binary data to PCRE, and if grep uses PCRE_NO_UTF8_CHECK, undefined behavior will result (maybe infinite loop, core dump, etc.). We can't have undefined behavior in grep. A simple fix is to avoid using PCRE_NO_UTF8_CHECK so I installed the attached patch to do that. Perhaps we can think of a better way at some point. In the meantime I'm taking the liberty of closing Bug#17245 and Bug#16586.

Attachment: 0001-grep-P-now-rejects-invalid-input-sequences-in-UTF-8-.patch
Description: Text Data


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]