[Pcre-svn] [489] code/trunk: Fix workspace overflow for deep…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [489] code/trunk: Fix workspace overflow for deep nested parentheses with (*ACCEPT).
Revision: 489
          http://www.exim.org/viewvc/pcre2?view=rev&revision=489
Author:   ph10
Date:     2016-02-10 18:24:02 +0000 (Wed, 10 Feb 2016)
Log Message:
-----------
Fix workspace overflow for deep nested parentheses with (*ACCEPT).


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput8
    code/trunk/testdata/testoutput8-16-2
    code/trunk/testdata/testoutput8-16-3
    code/trunk/testdata/testoutput8-16-4
    code/trunk/testdata/testoutput8-32-2
    code/trunk/testdata/testoutput8-32-3
    code/trunk/testdata/testoutput8-32-4
    code/trunk/testdata/testoutput8-8-2
    code/trunk/testdata/testoutput8-8-3
    code/trunk/testdata/testoutput8-8-4


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/ChangeLog    2016-02-10 18:24:02 UTC (rev 489)
@@ -58,7 +58,11 @@
 assertion, caused pcre2test to output a very large number of spaces when the 
 callout was taken, making the program appearing to loop.


+12. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
+nested set of parentheses of sufficient size caused an overflow of the
+compiling workspace (which was diagnosed, but of course is not desirable).

+
Version 10.21 12-January-2016
-----------------------------


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/src/pcre2_compile.c    2016-02-10 18:24:02 UTC (rev 489)
@@ -5901,10 +5901,22 @@
               goto FAILED;
               }
             cb->had_accept = TRUE;
+            
+            /* In the first pass, just accumulate the length required;
+            otherwise hitting (*ACCEPT) inside many nested parentheses can
+            cause workspace overflow. */
+              
             for (oc = cb->open_caps; oc != NULL; oc = oc->next)
               {
-              *code++ = OP_CLOSE;
-              PUT2INC(code, 0, oc->number);
+              if (lengthptr != NULL)
+                {
+                *lengthptr += CU2BYTES(1) + IMM2_SIZE; 
+                }
+              else
+                {       
+                *code++ = OP_CLOSE;
+                PUT2INC(code, 0, oc->number);
+                } 
               }
             setverb = *code++ =
               (cb->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;


Modified: code/trunk/testdata/testinput8
===================================================================
--- code/trunk/testdata/testinput8    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testinput8    2016-02-10 18:24:02 UTC (rev 489)
@@ -182,4 +182,6 @@


/((?1)(?2)(?3)(?4)(?5)(?6)(?7)(?8)(?9)(?9)(?8)(?7)(?6)(?5)(?4)(?3)(?2)(?1)(?0)){2,}()()()()()()()()()/debug

+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-16-2
===================================================================
--- code/trunk/testdata/testoutput8-16-2    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-16-2    2016-02-10 18:24:02 UTC (rev 489)
@@ -1027,4 +1027,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 186 at offset 490: regular expression is too complicated
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-16-3
===================================================================
--- code/trunk/testdata/testoutput8-16-3    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-16-3    2016-02-10 18:24:02 UTC (rev 489)
@@ -1023,4 +1023,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-16-4
===================================================================
--- code/trunk/testdata/testoutput8-16-4    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-16-4    2016-02-10 18:24:02 UTC (rev 489)
@@ -1023,4 +1023,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-32-2
===================================================================
--- code/trunk/testdata/testoutput8-32-2    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-32-2    2016-02-10 18:24:02 UTC (rev 489)
@@ -1023,4 +1023,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-32-3
===================================================================
--- code/trunk/testdata/testoutput8-32-3    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-32-3    2016-02-10 18:24:02 UTC (rev 489)
@@ -1023,4 +1023,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-32-4
===================================================================
--- code/trunk/testdata/testoutput8-32-4    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-32-4    2016-02-10 18:24:02 UTC (rev 489)
@@ -1023,4 +1023,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-8-2
===================================================================
--- code/trunk/testdata/testoutput8-8-2    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-8-2    2016-02-10 18:24:02 UTC (rev 489)
@@ -1026,4 +1026,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-8-3
===================================================================
--- code/trunk/testdata/testoutput8-8-3    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-8-3    2016-02-10 18:24:02 UTC (rev 489)
@@ -1024,4 +1024,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8

Modified: code/trunk/testdata/testoutput8-8-4
===================================================================
--- code/trunk/testdata/testoutput8-8-4    2016-02-06 16:40:59 UTC (rev 488)
+++ code/trunk/testdata/testoutput8-8-4    2016-02-10 18:24:02 UTC (rev 489)
@@ -1022,4 +1022,7 @@
 May match empty string
 Subject length lower bound = 0


+/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
+Failed: error 114 at offset 509: missing closing parenthesis
+
# End of testinput8