[Pcre-svn] [1578] code/trunk: Fix bug for classes containing…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1578] code/trunk: Fix bug for classes containing \\ sequences.
Revision: 1578
          http://vcs.pcre.org/viewvc?view=rev&revision=1578
Author:   ph10
Date:     2015-07-20 17:27:31 +0100 (Mon, 20 Jul 2015)
Log Message:
-----------
Fix bug for classes containing \\ 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 07:53:12 UTC (rev 1577)
+++ code/trunk/ChangeLog    2015-07-20 16:27:31 UTC (rev 1578)
@@ -84,7 +84,11 @@
 21. Fix infinite recursion in the JIT compiler when certain patterns such as
     /(?:|a|){100}x/ are analysed.


+22. Some patterns with character classes involving [: and \\ were incorrectly
+    compiled and could cause reading from uninitialized memory or an incorrect
+    error diagnosis.


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


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2015-07-20 07:53:12 UTC (rev 1577)
+++ code/trunk/pcre_compile.c    2015-07-20 16:27:31 UTC (rev 1578)
@@ -3905,11 +3905,11 @@
 The problem in trying to be exactly like Perl is in the handling of escapes. We
 have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX
 class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code
-below handles the special case of \], but does not try to do any other escape
-processing. This makes it different from Perl for cases such as [:l\ower:]
-where Perl recognizes it as the POSIX class "lower" but PCRE does not recognize
-"l\ower". This is a lesser evil than not diagnosing bad classes when Perl does,
-I think.
+below handles the special cases \\ and \], but does not try to do any other
+escape processing. This makes it different from Perl for cases such as
+[:l\ower:] where Perl recognizes it as the POSIX class "lower" but PCRE does
+not recognize "l\ower". This is a lesser evil than not diagnosing bad classes
+when Perl does, I think.


 A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
 It seems that the appearance of a nested POSIX class supersedes an apparent
@@ -3936,7 +3936,9 @@
 terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
 for (++ptr; *ptr != CHAR_NULL; ptr++)
   {
-  if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
+  if (*ptr == CHAR_BACKSLASH && 
+      (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
+       ptr[1] == CHAR_BACKSLASH))
     ptr++;
   else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
   else


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-07-20 07:53:12 UTC (rev 1577)
+++ code/trunk/testdata/testinput2    2015-07-20 16:27:31 UTC (rev 1578)
@@ -4184,4 +4184,6 @@


/(?(R))*+/BZ

+/[[:\\](?'abc')[a:]/
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-07-20 07:53:12 UTC (rev 1577)
+++ code/trunk/testdata/testoutput2    2015-07-20 16:27:31 UTC (rev 1578)
@@ -14502,4 +14502,6 @@
         End
 ------------------------------------------------------------------


+/[[:\\](?'abc')[a:]/
+
/-- End of testinput2 --/