An integer overflow flaw, leading to a heap-based buffer overflow, was found in the way grep parsed large lines of data. An attacker able to trick a user into running grep on a specially crafted data file could use this flaw to crash grep or, potentially, execute arbitrary code with the privileges of the user running grep.
An integer overflow leading to a heap-based buffer overflow was found in the way grep, A utility used to search through textual input for lines which contain a match to a specified pattern, parsed large lines of data. This flaw could use used to crash grep or potentially execute arbitrary code, if a local user was tricked into running grep on a specially crafted data file.
Upstream suggests that this issue only affects grep < 2.11
This issue affects the version of grep package as shipped with Fedora-16.
This issue does NOT affect the version of grep package as shipped with Fedora-17.
I am unable to reproduce the crash on F16.
64 bit machine with 4 GB RAM:
# perl -e 'print "x"x(2**31)' | grep x > /dev/null
grep: memory exhausted
# grep --version
grep (GNU grep) 2.9
This issue did not affect the version of grep as shipped with Red Hat Enterprise Linux 5.
Created attachment 686585 [details]
This is proposed fix/workaround for the problem. It is not clean solution, but it shouldn't have side-effects.
Created attachment 686605 [details]
Proposed fix (to cover boundary case)
# perl -e 'print "x"x(1073741823)' | LANG=c grep x > /dev/null
# perl -e 'print "x"x(1073741824)' | LANG=c grep x > /dev/null
grep: line too long
This issue has been addressed in the following products:
Red Hat Enterprise Linux 6
Via RHSA-2015:1447 https://rhn.redhat.com/errata/RHSA-2015-1447.html