On Tue, Apr 15, 2014 at 4:48 PM, Norihiro Tanaka <[email protected]> wrote:
> I confirmed that this bug is also avoided by re-compiling PCRE with
> --enable-git option.
>
> PCRE without --enable-git:
> $ env LC_ALL=en_US.utf8 src/grep -P '.?ma' test-image.png
> Segmentation fault (core dumped)
>
> PCRE with --enable-git:
> $ env LC_ALL=en_US.utf8 src/grep -P '.?ma' test-image.png
> Binary file ../test-image.png matches

Thank you.
I presume you meant --enable-jit.
However, even when building the latest pcre like this:

  ./configure --enable-unicode-properties --enable-utf8 --enable-jit && make

and linking grep with its resulting .a file, my new pcre-infloop test
still failed.
However, with the attached patch to pcre, it passes:
From 9080a9509f62bfae6b12ca5791613c8e4d3dedd6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Tue, 15 Apr 2014 11:37:46 -0700
Subject: [PATCH] avoid infloop

---
 pcre_exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pcre_exec.c b/pcre_exec.c
index 5dec992..108fd95 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -5940,7 +5940,7 @@ for (;;)
           RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
           eptr--;
-          BACKCHAR(eptr);
+          while(eptr > pp && (*eptr & 0xc0) == 0x80) eptr--;
           if (ctype == OP_ANYNL && eptr > pp  && UCHAR21(eptr) == CHAR_NL &&
               UCHAR21(eptr - 1) == CHAR_CR) eptr--;
           }
-- 
1.9.2.459.g68773ac

Reply via email to