Subject: bug#24161: [PATCH 2/2] sed: speed up matching by reguler expression with dfa matcher

From: Norihiro Tanaka <[email-masked]>
Date: Tue, 09 Aug 2016 22:59:33 +0900

On Mon, 8 Aug 2016 18:33:26 -0700
Jim Meyering <[email-masked]> wrote:

> On Mon, Aug 8, 2016 at 5:53 PM, Jim Meyering <[email-masked]> wrote:
> > On Mon, Aug 8, 2016 at 4:29 PM, Norihiro Tanaka <[email-masked]> wrote:
> ...
> >> Thanks for adjusting.  I agree the all changes.
> >
> > Pushed.
> 
> Oops. I had not run ASAN-enabled tests with this patch.
> Doing that exposed many test failures like this:
> 
> LC_ALL=C  ./sed/sed -f ./testsuite/madding.sed \
>         < ./testsuite/madding.inp | LC_ALL=C tr -d \\r > madding.out
> =================================================================
> ==8797==ERROR: AddressSanitizer: heap-buffer-overflow on address
> 0x622000019646 at pc 0x0000004e98ce bp 0x7ffee5d23130 sp
> 0x7ffee5d23128
> READ of size 1 at 0x622000019646 thread T0
>     #0 0x4e98cd in dfaexec_main sed/dfa.c:3078
>     #1 0x4e98cd in dfaexec_sb sed/dfa.c:3242
>     #2 0x4ece9f in dfaexec sed/dfa.c:3263
>     #3 0x4f64ba in match_regex sed/regexp.c:270
>     #4 0x4f46ac in do_subst sed/execute.c:1024
>     #5 0x4f46ac in execute_program sed/execute.c:1510
>     #6 0x4f5997 in process_files sed/execute.c:1678
>     #7 0x4f6f64 in main sed/sed.c:363
>     #8 0x7fe665f89730 in __libc_start_main (/lib64/libc.so.6+0x20730)
>     #9 0x407118 in _start (/home/j/w/co/sed/sed/sed+0x407118)
> 
> which I am fixing with this patch:

Special thanks for catching up abd fixing heap-buffer-overflow bug.