bug-grep
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: exercise two recently-fixed bugs


From: Paolo Bonzini
Subject: Re: [PATCH] tests: exercise two recently-fixed bugs
Date: Fri, 16 Mar 2012 09:28:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

Il 09/03/2012 12:32, Jim Meyering ha scritto:
> 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
> 
> 

Should this be marked as expensive?

Paolo




reply via email to

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