[Pcre-svn] [1579] code/trunk: Fix "run for ever" bug for dee…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [1579] code/trunk: Fix "run for ever" bug for deeply nested [: sequences.
Revision: 1579
          http://vcs.pcre.org/viewvc?view=rev&revision=1579
Author:   ph10
Date:     2015-07-21 14:47:22 +0100 (Tue, 21 Jul 2015)
Log Message:
-----------
Fix "run for ever" bug for deeply nested [: sequences.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-07-20 16:27:31 UTC (rev 1578)
+++ code/trunk/ChangeLog    2015-07-21 13:47:22 UTC (rev 1579)
@@ -88,7 +88,10 @@
     compiled and could cause reading from uninitialized memory or an incorrect
     error diagnosis.


+16. Pathological patterns containing many nested occurrences of [: caused 
+    pcre_compile() to run for a very long time.


+
Version 8.37 28-April-2015
--------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2015-07-20 16:27:31 UTC (rev 1578)
+++ code/trunk/pcre_compile.c    2015-07-21 13:47:22 UTC (rev 1579)
@@ -3940,19 +3940,12 @@
       (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
        ptr[1] == CHAR_BACKSLASH))
     ptr++;
-  else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
-  else
+  else if ((*ptr == CHAR_LEFT_SQUARE_BRACKET && ptr[1] == terminator) ||
+            *ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
+  else if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
     {
-    if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
-      {
-      *endptr = ptr;
-      return TRUE;
-      }
-    if (*ptr == CHAR_LEFT_SQUARE_BRACKET &&
-         (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
-          ptr[1] == CHAR_EQUALS_SIGN) &&
-        check_posix_syntax(ptr, endptr))
-      return FALSE;
+    *endptr = ptr;
+    return TRUE;
     }
   }
 return FALSE;


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-07-20 16:27:31 UTC (rev 1578)
+++ code/trunk/testdata/testinput2    2015-07-21 13:47:22 UTC (rev 1579)
@@ -4186,4 +4186,6 @@


/[[:\\](?'abc')[a:]/

+"[[[.\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[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-07-20 16:27:31 UTC (rev 1578)
+++ code/trunk/testdata/testoutput2    2015-07-21 13:47:22 UTC (rev 1579)
@@ -14504,4 +14504,7 @@


/[[:\\](?'abc')[a:]/

+"[[[.\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[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
+Failed: missing terminating ] for character class at offset 353
+
/-- End of testinput2 --/