bug-grep
[Top][All Lists]
Advanced

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

grep: lseek: Illegal seek


From: Clifford Wolf
Subject: grep: lseek: Illegal seek
Date: Fri, 9 Nov 2007 15:24:05 +0100
User-agent: Mutt/1.5.16 (2007-06-09)

Hi,

I think I have found a bug in grep 2.5.3:

--snip--
$ echo foobar | grep foobar /etc/passwd -
grep: lseek: Illegal seek
--snap--

seams like reset() in grep.c is using the first argument to determine if
the current file is seekable, which causes an error if the first argument
is seekable and the 2nd isn't. unfortunately I do not know enough about
grep internals to provide a clean fix.

the following hack made the error go away for me:

--snip--
--- ./src/grep.c.orig   2007-11-09 15:05:44.000000000 +0100
+++ ./src/grep.c        2007-11-09 15:17:23.000000000 +0100
@@ -463,8 +463,9 @@
          bufoffset = lseek (fd, 0, SEEK_CUR);
          if (bufoffset < 0)
            {
-             error (0, errno, "lseek");
-             return 0;
+             goto lseek_failed_hack;
+             // error (0, errno, "lseek");
+             // return 0;
            }
        }
 #if defined(HAVE_MMAP)
@@ -474,6 +475,7 @@
     }
   else
     {
+lseek_failed_hack:;
 #if defined(HAVE_MMAP)
       bufmapped = 0;
 #endif
--snap--

yours,
 - clifford

-- 
Qrpelcgvat ebg13 ivbyngrf gur QZPN! Cercner gb or fhrq!!




reply via email to

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