GNU bug report logs - #15472
segmentation fault if input line is too long

Previous Next

Package: grep;

Reported by: Holger Then <Holger.Then <at> bristol.ac.uk>

Date: Fri, 27 Sep 2013 06:28:12 UTC

Severity: normal

Tags: notabug

Done: Jim Meyering <meyering <at> fb.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Holger Then <Holger.Then <at> bristol.ac.uk>
To: bug-grep <at> gnu.org
Subject: segmentation fault if input line is too long
Date: Thu, 26 Sep 2013 14:21:54 +0200 (CEST)
If grep searches through a line that is longer than
INT_MAX (= 2147483647) characters, then grep causes
a segmentation fault.

Interestingly this bug does not occur with fgrep or
with grep -F

Kind regards,
Holger


$ wc grep_bug.txt
         1   12200610 3281667946 grep_bug.txt
$ fgrep -e 1 grep_bug.txt | wc
      1 12200610 3281667946
$ grep -Fe 1 grep_bug.txt | wc
      1 12200610 3281667946
$ grep -e 1 grep_bug.txt | wc
      0       0       0
$ grep -e 1 grep_bug.txt
Segmentation fault

$ tail -c 2147483647 grep_bug.txt | grep -e 1 | wc
      1 8385663 2147483647
$ tail -c 2147483648 grep_bug.txt | grep -e 1 | wc
      0       0       0
$ tail -c 2147483648 grep_bug.txt | grep -e 1
Segmentation fault

$ uname 
-a
Linux c-0-0.local 2.6.32-358.11.1.el6.x86_64 #1 SMP Wed Jun 12 03:34:52 
UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ grep --version
GNU grep 2.6.3

Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.





This bug report was last modified 11 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.