Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 158506 - grep segfaults when all of color, context, match, ignorecase set
Summary: grep segfaults when all of color, context, match, ignorecase set
Alias: None
Product: Fedora
Classification: Fedora
Component: grep
Version: 3
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Mike McLean
: 158536 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2005-05-23 04:20 UTC by Doug Maxey
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-05-23 17:01:35 UTC

Attachments (Terms of Use)
patch to test return from memchr() (deleted)
2005-05-23 04:20 UTC, Doug Maxey
no flags Details | Diff

Description Doug Maxey 2005-05-23 04:20:00 UTC
Description of problem:
When using the command 
grep --color=auto --ignore-case --before-context 1 --after-context=4 --max-count
a segfault is produced in for the _last_ match in search.c

Version-Release number of selected component (if applicable):

How reproducible:

Actual results:
grep segfaults.

Expected results:
colorized context printed up to match times.

Additional info:
The faulting function is src/search.c::EGexecute::memchr().  The starting
address "beg" is passed as 1.  This was caused by the NULL return from the
previous call to memchr() and the loop continues.

Comment 1 Doug Maxey 2005-05-23 04:20:00 UTC
Created attachment 114697 [details]
patch to test return from memchr()

Comment 2 Tim Waugh 2005-05-23 12:38:52 UTC

Complete test case:

(echo foo ; echo foo) | \
  grep --color=auto --ignore-case --before-context=1 \
       --after-context=4 --max-count=1 foo

Comment 3 Doug Maxey 2005-05-23 13:13:57 UTC
*** Bug 158536 has been marked as a duplicate of this bug. ***

Comment 4 Tim Waugh 2005-05-23 17:01:35 UTC
Submitted upstream, as this check is missing in unpatched 2.5.1a.

Note You need to log in before you can comment on or make changes to this bug.