[Pcre-svn] [934] code/trunk: Ensure all match limit tests se…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [934] code/trunk: Ensure all match limit tests set a limit, don' t rely on the default.
Revision: 934
          http://www.exim.org/viewvc/pcre2?view=rev&revision=934
Author:   ph10
Date:     2018-04-29 16:07:44 +0100 (Sun, 29 Apr 2018)
Log Message:
-----------
Ensure all match limit tests set a limit, don't rely on the default.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_jit_test.c
    code/trunk/testdata/testinput15
    code/trunk/testdata/testinput17
    code/trunk/testdata/testinput6
    code/trunk/testdata/testoutput15
    code/trunk/testdata/testoutput17
    code/trunk/testdata/testoutput6


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/ChangeLog    2018-04-29 15:07:44 UTC (rev 934)
@@ -63,7 +63,11 @@
 14. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as 
 EOF. The test looks to have come from a fuzzer.


+15. If PCRE2 was built with a default match limit a lot greater than the
+default default of 10 000 000, some JIT tests of the match limit no longer
+failed. All such tests now set 10 000 000 as the upper limit.

+
Version 10.31 12-February-2018
------------------------------


Modified: code/trunk/src/pcre2_jit_test.c
===================================================================
--- code/trunk/src/pcre2_jit_test.c    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/src/pcre2_jit_test.c    2018-04-29 15:07:44 UTC (rev 934)
@@ -1331,8 +1331,9 @@
                 ovector8_2[i] = -2;
         }
         if (re8) {
+                        (void)pcre2_set_match_limit_8(mcontext8, 10000000); 
             return_value8[1] = pcre2_match_8(re8, (PCRE2_SPTR8)current->input, strlen(current->input),
-                current->start_offset & OFFSET_MASK, current->match_options, mdata8_2, NULL);
+                current->start_offset & OFFSET_MASK, current->match_options, mdata8_2, mcontext8);


             if (pcre2_jit_compile_8(re8, jit_compile_mode)) {
                 printf("\n8 bit: JIT compiler does not support \"%s\"\n", current->pattern);
@@ -1375,8 +1376,9 @@
             else
                 length16 = copy_char8_to_char16((PCRE2_SPTR8)current->input, regtest_buf16, REGTEST_MAX_LENGTH16);


+                        (void)pcre2_set_match_limit_16(mcontext16, 10000000); 
             return_value16[1] = pcre2_match_16(re16, regtest_buf16, length16,
-                current->start_offset & OFFSET_MASK, current->match_options, mdata16_2, NULL);
+                current->start_offset & OFFSET_MASK, current->match_options, mdata16_2, mcontext16);


             if (pcre2_jit_compile_16(re16, jit_compile_mode)) {
                 printf("\n16 bit: JIT compiler does not support \"%s\"\n", current->pattern);
@@ -1419,8 +1421,9 @@
             else
                 length32 = copy_char8_to_char32((PCRE2_SPTR8)current->input, regtest_buf32, REGTEST_MAX_LENGTH32);


+                        (void)pcre2_set_match_limit_32(mcontext32, 10000000); 
             return_value32[1] = pcre2_match_32(re32, regtest_buf32, length32,
-                current->start_offset & OFFSET_MASK, current->match_options, mdata32_2, NULL);
+                current->start_offset & OFFSET_MASK, current->match_options, mdata32_2, mcontext32);


             if (pcre2_jit_compile_32(re32, jit_compile_mode)) {
                 printf("\n32 bit: JIT compiler does not support \"%s\"\n", current->pattern);


Modified: code/trunk/testdata/testinput15
===================================================================
--- code/trunk/testdata/testinput15    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testinput15    2018-04-29 15:07:44 UTC (rev 934)
@@ -46,32 +46,45 @@
 /(*LIMIT_DEPTH=4294967280)abc/I


 /(a+)*zz/
+\= Expect no match
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=3000


 /(a+)*zz/
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=10


 /(*LIMIT_MATCH=3000)(a+)*zz/I
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=60000


 /(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I
+\= Expect limit exceeded
     aaaaaaaaaaaaaz


 /(*LIMIT_MATCH=60000)(a+)*zz/I
+\= Expect no match
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=3000


 /(*LIMIT_DEPTH=10)(a+)*zz/I
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=1000


 /(*LIMIT_DEPTH=10)(*LIMIT_DEPTH=1000)(a+)*zz/I
+\= Expect no match
     aaaaaaaaaaaaaz


 /(*LIMIT_DEPTH=1000)(a+)*zz/I
+\= Expect no match
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=10


# These three have infinitely nested recursions.

Modified: code/trunk/testdata/testinput17
===================================================================
--- code/trunk/testdata/testinput17    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testinput17    2018-04-29 15:07:44 UTC (rev 934)
@@ -160,10 +160,13 @@
     aaaaaaaaaaaaaz\=match_limit=3000


 /(*LIMIT_MATCH=3000)(a+)*zz/I
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=60000


 /(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I
+\= Expect limit exceeded
     aaaaaaaaaaaaaz


/(*LIMIT_MATCH=60000)(a+)*zz/I
@@ -175,12 +178,15 @@
# These three have infinitely nested recursions.

 /((?2))((?1))/
+\= Expect JIT stack limit reached
     abc


 /((?(R2)a+|(?1)b))()/
+\= Expect JIT stack limit reached
     aaaabcde


 /(?(R)a*(?1)|((?R))b)/
+\= Expect JIT stack limit reached
     aaaabcde


# Invalid options disable JIT when called via pcre2_match(), causing the
@@ -277,7 +283,8 @@
/[axm]{7}/

 /(.|.)*?bx/
-    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax
+\= Expect limit exceeded
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax\=match_limit=10000000


# Test JIT disable


Modified: code/trunk/testdata/testinput6
===================================================================
--- code/trunk/testdata/testinput6    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testinput6    2018-04-29 15:07:44 UTC (rev 934)
@@ -4938,6 +4938,7 @@
     abcde\=aftertext


/(*LIMIT_MATCH=100).*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00?\x00\x00\x00?H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[?\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););/no_dotstar_anchor
+\= Expect limit exceeded
.*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00?\x00\x00\x00?H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[?\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););

/\n/firstline

Modified: code/trunk/testdata/testoutput15
===================================================================
--- code/trunk/testdata/testoutput15    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testoutput15    2018-04-29 15:07:44 UTC (rev 934)
@@ -124,12 +124,15 @@
 Subject length lower bound = 3


 /(a+)*zz/
+\= Expect no match
     aaaaaaaaaaaaaz
 No match
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=3000
 Failed: error -47: match limit exceeded


 /(a+)*zz/
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=10
 Failed: error -53: matching depth limit exceeded


@@ -139,8 +142,10 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
 Failed: error -47: match limit exceeded
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=60000
 Failed: error -47: match limit exceeded


@@ -150,6 +155,7 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
 Failed: error -47: match limit exceeded


@@ -159,8 +165,10 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect no match
     aaaaaaaaaaaaaz
 No match
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=3000
 Failed: error -47: match limit exceeded


@@ -170,8 +178,10 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
 Failed: error -53: matching depth limit exceeded
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=1000
 Failed: error -53: matching depth limit exceeded


@@ -181,6 +191,7 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect no match
     aaaaaaaaaaaaaz
 No match


@@ -190,8 +201,10 @@
 Starting code units: a z 
 Last code unit = 'z'
 Subject length lower bound = 2
+\= Expect no match
     aaaaaaaaaaaaaz
 No match
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=depth_limit=10
 Failed: error -53: matching depth limit exceeded



Modified: code/trunk/testdata/testoutput17
===================================================================
--- code/trunk/testdata/testoutput17    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testoutput17    2018-04-29 15:07:44 UTC (rev 934)
@@ -300,8 +300,10 @@
 Last code unit = 'z'
 Subject length lower bound = 2
 JIT compilation was successful
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
 Failed: error -47: match limit exceeded
+\= Expect limit exceeded
     aaaaaaaaaaaaaz\=match_limit=60000
 Failed: error -47: match limit exceeded


@@ -312,6 +314,7 @@
 Last code unit = 'z'
 Subject length lower bound = 2
 JIT compilation was successful
+\= Expect limit exceeded
     aaaaaaaaaaaaaz
 Failed: error -47: match limit exceeded


@@ -332,14 +335,17 @@
# These three have infinitely nested recursions.

 /((?2))((?1))/
+\= Expect JIT stack limit reached
     abc
 Failed: error -46: JIT stack limit reached


 /((?(R2)a+|(?1)b))()/
+\= Expect JIT stack limit reached
     aaaabcde
 Failed: error -46: JIT stack limit reached


 /(?(R)a*(?1)|((?R))b)/
+\= Expect JIT stack limit reached
     aaaabcde
 Failed: error -46: JIT stack limit reached


@@ -516,7 +522,8 @@
/[axm]{7}/

 /(.|.)*?bx/
-    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax
+\= Expect limit exceeded
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax\=match_limit=10000000
 Failed: error -47: match limit exceeded


# Test JIT disable

Modified: code/trunk/testdata/testoutput6
===================================================================
--- code/trunk/testdata/testoutput6    2018-04-28 16:05:48 UTC (rev 933)
+++ code/trunk/testdata/testoutput6    2018-04-29 15:07:44 UTC (rev 934)
@@ -7761,6 +7761,7 @@
  0+ 


/(*LIMIT_MATCH=100).*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00?\x00\x00\x00?H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[?\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););/no_dotstar_anchor
+\= Expect limit exceeded
.*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00?\x00\x00\x00?H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[?\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););
Failed: error -47: match limit exceeded