[Top][All Lists]

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

[bug #21342] grep --colour=yes -i ".*" hangs forever (+patch)

From: spiritus
Subject: [bug #21342] grep --colour=yes -i ".*" hangs forever (+patch)
Date: Sun, 14 Oct 2007 22:22:55 +0000
User-agent: Opera/9.23 (X11; Linux i686; U; en)


                 Summary: grep --colour=yes -i ".*" hangs forever (+patch)
                 Project: grep
            Submitted by: spiritus999
            Submitted on: Воскресенье 14.10.2007 at 22:22
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any



I have accidently found, that there is a proble with grep 2.5.1a and early
versions having --colour support. It hangs on the following test case:
echo test|grep --colour=yes -i ".*"

It loops forever in the while-loop at grep-2.5.1a/src/grep.c beginning from
line 570:

          while ((match_offset = (*execute) (ibeg, ilim-ibeg, &match_size,
                 != (size_t) -1)
              char const *b = beg + match_offset;
              if (b == lim)
              fwrite (beg, sizeof (char), match_offset, stdout);
              printf ("\33[%sm", grep_color);
              fwrite (b, sizeof (char), match_size, stdout);
              fputs ("\33[00m", stdout);
              beg = b + match_size;
              ibeg = ibeg + match_offset + match_size;

gdb show that match_offset=0, so b = beg and it and it loops forever, because
match_offset != -1 and b != lim. 
It seems there is a fix for the same problem, but for different situation
when (match_icase==0) i.e. grep --colour without switch "-i".
Suggested patch attached.


File Attachments:

Date: Воскресенье 14.10.2007 at 22:22  Name:
grep_colorize_fix.patch  Size: 649B   By: spiritus999



Reply to this item at:


  Message sent via/by Savannah

reply via email to

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