[Pcre-svn] [1638] code/trunk: Fix non-diagnosis of missing a…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1638] code/trunk: Fix non-diagnosis of missing assertion after (?(?C).
Revision: 1638
          http://vcs.pcre.org/viewvc?view=rev&revision=1638
Author:   ph10
Date:     2016-02-27 18:44:41 +0000 (Sat, 27 Feb 2016)
Log Message:
-----------
Fix non-diagnosis of missing assertion after (?(?C).


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    2016-02-27 17:55:24 UTC (rev 1637)
+++ code/trunk/ChangeLog    2016-02-27 18:44:41 UTC (rev 1638)
@@ -64,6 +64,10 @@
 15. pcretest went into a loop if global matching was requested with an ovector
     size less than 2. It now gives an error message. This bug was found by
     afl-fuzz.
+    
+16. An invalid pattern fragment such as (?(?C)0 was not diagnosing an error 
+    ("assertion expected") when (?(?C) was not followed by an opening 
+    parenthesis.



Version 8.38 23-November-2015

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2016-02-27 17:55:24 UTC (rev 1637)
+++ code/trunk/pcre_compile.c    2016-02-27 18:44:41 UTC (rev 1638)
@@ -485,7 +485,7 @@
   "lookbehind assertion is not fixed length\0"
   "malformed number or name after (?(\0"
   "conditional group contains more than two branches\0"
-  "assertion expected after (?(\0"
+  "assertion expected after (?( or (?(?C)\0"
   "(?R or (?[+-]digits must be followed by )\0"
   /* 30 */
   "unknown POSIX class name\0"
@@ -6771,6 +6771,15 @@
           for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break;
           if (ptr[i] == CHAR_RIGHT_PARENTHESIS)
             tempptr += i + 1;
+
+          /* tempptr should now be pointing to the opening parenthesis of the
+          assertion condition. */
+
+          if (*tempptr != CHAR_LEFT_PARENTHESIS)
+            {
+            *errorcodeptr = ERR28;
+            goto FAILED;
+            }
           }


         /* For conditions that are assertions, check the syntax, and then exit


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2016-02-27 17:55:24 UTC (rev 1637)
+++ code/trunk/testdata/testinput2    2016-02-27 18:44:41 UTC (rev 1638)
@@ -4241,4 +4241,6 @@


/((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/

+/\N(?(?C)0?!.)*/
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2016-02-27 17:55:24 UTC (rev 1637)
+++ code/trunk/testdata/testoutput2    2016-02-27 18:44:41 UTC (rev 1638)
@@ -555,13 +555,13 @@
 Failed: malformed number or name after (?( at offset 4


/(?(?i))/
-Failed: assertion expected after (?( at offset 3
+Failed: assertion expected after (?( or (?(?C) at offset 3

/(?(abc))/
Failed: reference to non-existent subpattern at offset 7

/(?(?<ab))/
-Failed: assertion expected after (?( at offset 3
+Failed: assertion expected after (?( or (?(?C) at offset 3

/((?s)blah)\s+\1/I
Capturing subpattern count = 1
@@ -7870,7 +7870,7 @@
Failed: malformed number or name after (?( at offset 6

/(?(''))/
-Failed: assertion expected after (?( at offset 4
+Failed: assertion expected after (?( or (?(?C) at offset 4

/(?('R')stuff)/
Failed: reference to non-existent subpattern at offset 7
@@ -14346,7 +14346,7 @@
"((?2)+)((?1))"

"(?(?<E>.*!.*)?)"
-Failed: assertion expected after (?( at offset 3
+Failed: assertion expected after (?( or (?(?C) at offset 3

"X((?2)()*+){2}+"BZ
------------------------------------------------------------------
@@ -14667,4 +14667,7 @@

/((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/

+/\N(?(?C)0?!.)*/
+Failed: assertion expected after (?( or (?(?C) at offset 4
+
/-- End of testinput2 --/