summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-03-09 12:25:17 +0100
committerJim Meyering <meyering@redhat.com>2012-03-09 12:31:06 +0100
commitd0bb7f9c1505f08362dbf107d47d8d6795c93fbf (patch)
tree5457ca1e21f47c5f7094d0ce4917f6479885f9cc
parent4b2224681fbc297bf585630b679d8540a02b78d3 (diff)
downloadgrep-d0bb7f9c1505f08362dbf107d47d8d6795c93fbf.tar.gz
tests: exercise two recently-fixed bugs
* tests/repetition-overflow: New test for bugs fixed by commit v2.10-82-gcbbc1a4. * tests/Makefile.am (TESTS): Add it.
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/repetition-overflow19
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0a22ba6c..c2cd2f7d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@ TESTS = \
pcre-z \
prefix-of-multibyte \
r-dot \
+ repetition-overflow \
reversed-range-endpoints \
sjis-mb \
spencer1 \
diff --git a/tests/repetition-overflow b/tests/repetition-overflow
new file mode 100755
index 00000000..c92de237
--- /dev/null
+++ b/tests/repetition-overflow
@@ -0,0 +1,19 @@
+#!/bin/sh
+# These would fail (i.e., match erroneously) prior to grep-2.11.
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+xp1=4294967297 # 2^32+1
+xp2=4294967298 # 2^32+2
+
+fail=0
+
+# Before grep-2.11, when DFA-matching, a repetition count exceeding the
+# range of "unsigned int" would silently wrap around. Hence, 2^32+1
+# would be treated just like "1", and both of these would mistakenly match.
+
+echo abc | grep -E "b{$xp1}" > out 2>&1; test $? = 1 || fail=1
+compare out /dev/null || fail=1
+echo abbc | grep -E "b{1,$xp2}" > out 2>&1; test $? = 1 || fail=1
+compare out /dev/null || fail=1
+
+Exit $fail