GNU bug report logs - #18738
Reference of a uninitialized variable in grep -P

Previous Next

Package: grep;

Reported by: Norihiro Tanaka <noritnk <at> kcn.ne.jp>

Date: Wed, 15 Oct 2014 16:38:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18738 in the body.
You can then email your comments to 18738 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#18738; Package grep. (Wed, 15 Oct 2014 16:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Norihiro Tanaka <noritnk <at> kcn.ne.jp>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Wed, 15 Oct 2014 16:38:02 GMT) Full text and rfc822 format available.

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

From: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
To: bug-grep <at> gnu.org
Subject: Reference of a uninitialized variable in grep -P
Date: Thu, 16 Oct 2014 00:57:07 +0900
A variable validated_boundary is used in grep -P.  However, it isn't
initialized correctly.  I found that it causes reference of the
uninitialized variable and wrong result.

  $ echo . | env LC_ALL=C src/grep -P .
  $ echo . | env LC_ALL=en_US.utf8 src/grep -P .

We expect that they return each one line, but return each no line.  Their
test cases are also used to judge whether pcre option is enabled in tests.
So all tests with pcre option will be skipped by the bug.

Sorry, I have no idea to fix the bug.  BTW, the bug isn't reproduced in
grep-2.20 or prior.





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Wed, 15 Oct 2014 18:53:03 GMT) Full text and rfc822 format available.

Notification sent to Norihiro Tanaka <noritnk <at> kcn.ne.jp>:
bug acknowledged by developer. (Wed, 15 Oct 2014 18:53:03 GMT) Full text and rfc822 format available.

Message #10 received at 18738-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Norihiro Tanaka <noritnk <at> kcn.ne.jp>, 18738-done <at> debbugs.gnu.org
Subject: Re: bug#18738: Reference of a uninitialized variable in grep -P
Date: Wed, 15 Oct 2014 11:51:57 -0700
[Message part 1 (text/plain, inline)]
Thanks for reporting that.  It's a bug in one of the optimizations I 
recently added to work around the libpcre slownesses with UTF-8.  It's 
also a bug in our test cases, which should have caught the bug.  I fixed 
it with the attached patch.
[0001-grep-fix-off-by-one-bug-in-P-optimization.patch (text/x-patch, attachment)]

Information forwarded to bug-grep <at> gnu.org:
bug#18738; Package grep. (Wed, 15 Oct 2014 23:57:01 GMT) Full text and rfc822 format available.

Message #13 received at 18738-done <at> debbugs.gnu.org (full text, mbox):

From: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 18738-done <at> debbugs.gnu.org
Subject: Re: bug#18738: Reference of a uninitialized variable in grep -P
Date: Thu, 16 Oct 2014 08:56:05 +0900
[Message part 1 (text/plain, inline)]
Paul Eggert wrote:
> Thanks for reporting that.  It's a bug in one of the optimizations I
> recently added to work around the libpcre slownesses with UTF-8.
> It's also a bug in our test cases, which should have caught the bug.
> I fixed it with the attached patch.

Thanks for fixing that.

BTW, validation_boundary isn't initialized before pre-searching for an
empty line clearly.  As it's set to 0 (NULL pointer in many machine)
implicitly, it isn't a bug.  However, if you don't avoid to initialize it
by intent, could you consider an attached patch?

[0001-grep-initialized-validation_boundary-before-pre-sear.patch (text/plain, attachment)]

Information forwarded to bug-grep <at> gnu.org:
bug#18738; Package grep. (Thu, 16 Oct 2014 04:43:02 GMT) Full text and rfc822 format available.

Message #16 received at 18738-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
Cc: 18738-done <at> debbugs.gnu.org
Subject: Re: bug#18738: Reference of a uninitialized variable in grep -P
Date: Wed, 15 Oct 2014 21:42:36 -0700
Norihiro Tanaka wrote:

> BTW, validation_boundary isn't initialized before pre-searching for an
> empty line

Oh, so *that's* the uninitialized variable you were referring to!  Sorry, I 
didn't know.  Yes, it should be initialized; it's not portable to assume that 
NULL < valid pointers.  I installed your patch.

This whole area should be cleaned up, I think, but not just before a release.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 13 Nov 2014 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 192 days ago.

Previous Next


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