[Pcre-svn] [729] code/trunk: Fix capturing in conditional ne…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [729] code/trunk: Fix capturing in conditional negative assertions ended with (*ACCEPT).
Revision: 729
          http://www.exim.org/viewvc/pcre2?view=rev&revision=729
Author:   ph10
Date:     2017-04-03 19:02:07 +0100 (Mon, 03 Apr 2017)
Log Message:
-----------
Fix capturing in conditional negative assertions ended with (*ACCEPT).


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_match.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testoutput1


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-04-03 18:01:07 UTC (rev 728)
+++ code/trunk/ChangeLog    2017-04-03 18:02:07 UTC (rev 729)
@@ -29,7 +29,10 @@
       vector on the stack is not big enough to handle at least 10 frames. 
       Fixes oss-fuzz issue 783. 


-  (c) Handling of (*VERB)s in recursions was wrong in some cases. 
+  (c) Handling of (*VERB)s in recursions was wrong in some cases.
+  
+  (d) Captures in negative assertions that were used as conditions were not
+      happening if the assertion matched via (*ACCEPT).   


2. Now that pcre2_match() no longer uses recursive function calls (see above),
the "match limit recursion" value seems misnamed. It still exists, and limits

Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2017-04-03 18:01:07 UTC (rev 728)
+++ code/trunk/src/pcre2_match.c    2017-04-03 18:02:07 UTC (rev 729)
@@ -5332,17 +5332,14 @@


         switch(rrc)
           {
-          case MATCH_ACCEPT:
-          if (Lpositive)      /* Save captures if a positive assertion */
-            {
-            memcpy(Fovector,
-                  (char *)assert_accept_frame + offsetof(heapframe, ovector),
-                  assert_accept_frame->offset_top * sizeof(PCRE2_SIZE));
-            Foffset_top = assert_accept_frame->offset_top;
-            }
+          case MATCH_ACCEPT:  /* Save captures */
+          memcpy(Fovector,
+                (char *)assert_accept_frame + offsetof(heapframe, ovector),
+                assert_accept_frame->offset_top * sizeof(PCRE2_SIZE));
+          Foffset_top = assert_accept_frame->offset_top;


-          /* Fall through. In the case of a match for a positive assertion, the
-          captures have already been put into the current frame. */
+          /* Fall through. In the case of a match, the captures have already
+          been put into the current frame. */


           case MATCH_MATCH:
           condition = Lpositive;   /* TRUE for positive assertion */


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2017-04-03 18:01:07 UTC (rev 728)
+++ code/trunk/testdata/testinput1    2017-04-03 18:02:07 UTC (rev 729)
@@ -5905,4 +5905,16 @@
 /^(.|(.)(?1)?\2)$/
     abcba


+/^(?(?=(a))abc|def)/
+    abc
+
+/^(?(?!(a))def|abc)/
+    abc
+
+/^(?(?=(a)(*ACCEPT))abc|def)/
+    abc
+
+/^(?(?!(a)(*ACCEPT))def|abc)/
+    abc
+
 # End of testinput1 


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2017-04-03 18:01:07 UTC (rev 728)
+++ code/trunk/testdata/testoutput1    2017-04-03 18:02:07 UTC (rev 729)
@@ -9467,4 +9467,24 @@
  1: abcba
  2: a


+/^(?(?=(a))abc|def)/
+    abc
+ 0: abc
+ 1: a
+
+/^(?(?!(a))def|abc)/
+    abc
+ 0: abc
+ 1: a
+
+/^(?(?=(a)(*ACCEPT))abc|def)/
+    abc
+ 0: abc
+ 1: a
+
+/^(?(?!(a)(*ACCEPT))def|abc)/
+    abc
+ 0: abc
+ 1: a
+
 # End of testinput1