[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep branch, master, updated. v3.1-16-g51ef8ad
From: |
Jim Meyering |
Subject: |
grep branch, master, updated. v3.1-16-g51ef8ad |
Date: |
Sat, 16 Dec 2017 14:38:17 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".
The branch, master has been updated
via 51ef8adb2f7eeb073ba98be4f6baf56817e4d358 (commit)
from 6ada8b0a1b3f408ebf76e0cf7f7bb61019a70fdc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=51ef8adb2f7eeb073ba98be4f6baf56817e4d358
commit 51ef8adb2f7eeb073ba98be4f6baf56817e4d358
Author: Jim Meyering <address@hidden>
Date: Tue Dec 12 09:05:55 2017 -0800
grep: diagnose stack overflow rather than segfaulting
* bootstrap.conf (gnulib_modules): Add c-stack.
* src/grep.c: Include "c-stack.h".
(main): Call c_stack_action (NULL);
* tests/stack-overflow: New file.
* tests/Makefile.am (TESTS): Add name of new file.
* NEWS (Improvements): Mention it.
Interestingly, this bug does not afflict grep-2.5.4 or prior,
so it appeared to have been introduced with grep-2.6. However,
the origin is in glibc's regexp compiler, and I tracked it to
stack-aware parsing that was removed from glibc's regexp in 2002.
However, grep-2.5.4 was released in 2009. That version worked
(and still works, now) because it included and (by default) used
an old copy of glibc's regexp code.
Jeremy Feusi reported the grep segfault in https://bugs.gnu.org/29666.
I reported the glibc regexp bug in
https://sourceware.org/bugzilla/show_bug.cgi?id=22620
diff --git a/NEWS b/NEWS
index 51a1529..5a7a232 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,12 @@ GNU grep NEWS -*- outline
-*-
The --recursive (-r) option no longer fails on MS-Windows.
[bug introduced in grep 2.11]
+** Improvements
+
+ grep now diagnoses stack overflow. Before grep-2.6, the included
+ regexp code would detect it. Since 2.6, grep defaulted to using
+ glibc's regexp, which lost that capability.
+
* Noteworthy changes in release 3.1 (2017-07-02) [stable]
diff --git a/bootstrap.conf b/bootstrap.conf
index 73f1573..185cd19 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -27,6 +27,7 @@ alloca
announce-gen
argmatch
c-ctype
+c-stack
closeout
dfa
do-release-commit-and-tag
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 140aa20..a85b107 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
lib/argmatch.c
+lib/c-stack.c
lib/closeout.c
lib/dfa.c
lib/error.c
diff --git a/src/grep.c b/src/grep.c
index ad5cfa2..a444cf3 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -30,6 +30,7 @@
#include "argmatch.h"
#include "c-ctype.h"
+#include "c-stack.h"
#include "closeout.h"
#include "colorize.h"
#include "die.h"
@@ -2450,6 +2451,7 @@ main (int argc, char **argv)
init_localeinfo (&localeinfo);
atexit (clean_up_stdout);
+ c_stack_action (NULL);
last_recursive = 0;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 66fb461..4aca63b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -151,6 +151,7 @@ TESTS = \
skip-read \
spencer1 \
spencer1-locale \
+ stack-overflow \
status \
surrogate-pair \
symlink \
diff --git a/tests/stack-overflow b/tests/stack-overflow
new file mode 100755
index 0000000..2042ebc
--- /dev/null
+++ b/tests/stack-overflow
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Ensure a stack overflow no longer segfaults
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+# Too many open parentheses.
+printf %080000d 0|tr 0 '(' > in || framework_failure_
+echo grep: stack overflow > exp || framework_failure_
+
+fail=0
+returns_ 2 grep -E -f in >out 2>err || fail=1
+
+compare /dev/null out || fail=1
+compare exp err || fail=1
+
+Exit $fail
-----------------------------------------------------------------------
Summary of changes:
NEWS | 6 ++++++
bootstrap.conf | 1 +
po/POTFILES.in | 1 +
src/grep.c | 2 ++
tests/Makefile.am | 1 +
tests/stack-overflow | 16 ++++++++++++++++
6 files changed, 27 insertions(+)
create mode 100755 tests/stack-overflow
hooks/post-receive
--
grep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep branch, master, updated. v3.1-16-g51ef8ad,
Jim Meyering <=