[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: exercise two recently-fixed bugs
From: |
Jim Meyering |
Subject: |
[PATCH] tests: exercise two recently-fixed bugs |
Date: |
Fri, 09 Mar 2012 12:32:31 +0100 |
Here are tests for other bugs fixed by Paul Eggert's recent patches.
When a repetition count exceeded the range of "unsigned int",
it would silently wrap around. Hence, 2^32+1 would be treated
just like "1", and both of these would mistakenly match:
$ echo abc | /bin/grep -E "b{$((2**32+1))}"
abc
$ echo abbc | /bin/grep -E "b{1,$((2**32+2))}"
abbc
With the just-released grep-2.11, they do not match, as expected:
$ echo abc | grep -qE "b{$((2**32+1))}" || echo ok
ok
$ echo abbc | grep -qE "b{1,$((2**32+2))}" || echo ok
ok
>From d0bb7f9c1505f08362dbf107d47d8d6795c93fbf Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 9 Mar 2012 12:25:17 +0100
Subject: [PATCH] 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.
---
tests/Makefile.am | 1 +
tests/repetition-overflow | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
create mode 100755 tests/repetition-overflow
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0a22ba6..c2cd2f7 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 0000000..c92de23
--- /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
--
1.7.10.rc0.1.g890d0
- [PATCH] tests: exercise two recently-fixed bugs,
Jim Meyering <=
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paolo Bonzini, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Jim Meyering, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paolo Bonzini, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paolo Bonzini, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Jim Meyering, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paul Eggert, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Jim Meyering, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paul Eggert, 2012/03/16
- Re: [PATCH] tests: exercise two recently-fixed bugs, Jim Meyering, 2012/03/17
- Re: [PATCH] tests: exercise two recently-fixed bugs, Paul Eggert, 2012/03/17