Bug 517627

Summary: -w option ignored for files read after binary file, if -F option specified
Product: [Fedora] Fedora Reporter: Robin Green <greenrd>
Component: grepAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: jskarvad, kasal, lkundrak, pbonzini
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-04-13 10:32:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robin Green 2009-08-15 10:41:55 UTC
Description of problem:
If the -F and -w options are supplied to grep, and one of the files to be read is binary, any files read subsequently will be searched as if the -w option had not been specified.

Version-Release number of selected component (if applicable):
grep-2.5.3-5.fc12.i686

How reproducible:
Always

Steps to Reproduce:
1. /bin/grep -Fw hi /bin/ls <(echo hit)
  
Actual results:
Binary file /bin/ls matches
/proc/self/fd/63:hit


Expected results:
Binary file /bin/ls matches


Additional info:
A self-compiled binary of upstream grep 2.5.3 does not exhibit this bug, so this is very likely a bug in a Fedora modification to grep.

Comment 1 Robin Green 2009-08-15 12:56:23 UTC
This bug seems to only happen when the binary file contains a match.

Comment 2 Bug Zapper 2009-11-16 11:27:55 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 12 development cycle.
Changing version to '12'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 3 Robin Green 2010-03-05 06:59:43 UTC
This bug is not present in F13, in grep-2.5.4-1.fc13.i686. However, it is still present in F12, in grep-2.5.3-6.fc12.i686

Comment 4 Paolo Bonzini 2010-03-31 09:33:44 UTC
I cannot reproduce it with F12 on x86_64:

LC_ALL=C grep -Fw GNU /bin/ls <(echo GNUisance)
Binary file /bin/ls matches

(There's no "hi" in the 64-bit /bin/ls)

Comment 5 Robin Green 2010-03-31 13:41:15 UTC
Strange - the bug occurs for 2-character words, but not for a longer word I tried.

I suggest you use strings -a -2 to find a 2-character word, or copy the /bin/ls from a 32-bit system and use that.

Comment 6 Paolo Bonzini 2010-03-31 16:47:31 UTC
Nada:

$ grep -Fw hX /bin/ls <(echo hXX)
Binary file /bin/ls matches
$ LC_ALL=C grep -Fw hX /bin/ls <(echo hXX)
Binary file /bin/ls matches
$

Comment 7 Robin Green 2010-03-31 17:06:06 UTC
Maybe the bug only occurs on i686 then? Or only on 32-bit platforms?

Comment 8 Jaroslav Škarvada 2010-04-13 08:01:02 UTC
Robin, do you try with latest grep-2.6.3-1.fc12 (recently pushed to stable)?

https://admin.fedoraproject.org/updates/grep-2.6.3-1.fc12

Comment 9 Robin Green 2010-04-13 10:24:29 UTC
(In reply to comment #8)
> Robin, do you try with latest grep-2.6.3-1.fc12 (recently pushed to stable)?

Just tried it - bug does not occur with that. Thanks!