Blame SOURCES/pcre-8.32-Fix-run-for-ever-bug-for-deeply-nested-sequences.patch

cb67f2
From 9febe70a64d1669ec0151e51149af1e66bc04b5f Mon Sep 17 00:00:00 2001
cb67f2
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
cb67f2
Date: Tue, 21 Jul 2015 13:47:22 +0000
cb67f2
Subject: [PATCH] Fix "run for ever" bug for deeply nested [: sequences.
cb67f2
MIME-Version: 1.0
cb67f2
Content-Type: text/plain; charset=UTF-8
cb67f2
Content-Transfer-Encoding: 8bit
cb67f2
cb67f2
Ported to 8.32:
cb67f2
cb67f2
commit 485a930d11bfd1ba8c292fe14976f0a3e12c2b93
cb67f2
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
cb67f2
Date:   Tue Jul 21 13:47:22 2015 +0000
cb67f2
cb67f2
    Fix "run for ever" bug for deeply nested [: sequences.
cb67f2
cb67f2
    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1579 2f5784b3-3f2a-0410-8824-cb99058d5e15
cb67f2
cb67f2
Signed-off-by: Petr Písař <ppisar@redhat.com>
cb67f2
---
cb67f2
 pcre_compile.c       | 17 +++++------------
cb67f2
 testdata/testinput2  |  2 ++
cb67f2
 testdata/testoutput2 |  3 +++
cb67f2
 3 files changed, 10 insertions(+), 12 deletions(-)
cb67f2
cb67f2
diff --git a/pcre_compile.c b/pcre_compile.c
cb67f2
index aa7f4d6..8eb4b0f 100644
cb67f2
--- a/pcre_compile.c
cb67f2
+++ b/pcre_compile.c
cb67f2
@@ -2780,19 +2780,12 @@ for (++ptr; *ptr != CHAR_NULL; ptr++)
cb67f2
   {
cb67f2
   if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
cb67f2
     ptr++;
cb67f2
-  else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
cb67f2
-  else
cb67f2
+  else if ((*ptr == CHAR_LEFT_SQUARE_BRACKET && ptr[1] == terminator) ||
cb67f2
+            *ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
cb67f2
+  else if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
cb67f2
     {
cb67f2
-    if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
cb67f2
-      {
cb67f2
-      *endptr = ptr;
cb67f2
-      return TRUE;
cb67f2
-      }
cb67f2
-    if (*ptr == CHAR_LEFT_SQUARE_BRACKET &&
cb67f2
-         (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
cb67f2
-          ptr[1] == CHAR_EQUALS_SIGN) &&
cb67f2
-        check_posix_syntax(ptr, endptr))
cb67f2
-      return FALSE;
cb67f2
+    *endptr = ptr;
cb67f2
+    return TRUE;
cb67f2
     }
cb67f2
   }
cb67f2
 return FALSE;
cb67f2
diff --git a/testdata/testinput2 b/testdata/testinput2
cb67f2
index 2f460dc..61535de 100644
cb67f2
--- a/testdata/testinput2
cb67f2
+++ b/testdata/testinput2
cb67f2
@@ -3829,4 +3829,6 @@ settings of the anchored and startline bits. --/
cb67f2
 
cb67f2
 /(?=di(?<=(?1))|(?=(.))))/
cb67f2
 
cb67f2
+"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
cb67f2
+
cb67f2
 /-- End of testinput2 --/
cb67f2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
cb67f2
index 3c09fdf..ab1b2ca 100644
cb67f2
--- a/testdata/testoutput2
cb67f2
+++ b/testdata/testoutput2
cb67f2
@@ -12543,4 +12543,7 @@ No match
cb67f2
 /(?=di(?<=(?1))|(?=(.))))/
cb67f2
 Failed: unmatched parentheses at offset 23
cb67f2
 
cb67f2
+"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
cb67f2
+Failed: missing terminating ] for character class at offset 353
cb67f2
+
cb67f2
 /-- End of testinput2 --/
cb67f2
-- 
cb67f2
2.5.5
cb67f2