Ensure all match limit tests set a limit, don't rely on the default.

This commit is contained in:
Philip.Hazel 2018-04-29 15:07:44 +00:00
parent fb15b37b2c
commit 3fb01b0443
8 changed files with 54 additions and 5 deletions

View File

@ -63,6 +63,10 @@ matches for the ovector, no matches were displayed.
14. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as 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. 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 Version 10.31 12-February-2018
------------------------------ ------------------------------

View File

@ -1331,8 +1331,9 @@ static int regression_tests(void)
ovector8_2[i] = -2; ovector8_2[i] = -2;
} }
if (re8) { if (re8) {
(void)pcre2_set_match_limit_8(mcontext8, 10000000);
return_value8[1] = pcre2_match_8(re8, (PCRE2_SPTR8)current->input, strlen(current->input), 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)) { if (pcre2_jit_compile_8(re8, jit_compile_mode)) {
printf("\n8 bit: JIT compiler does not support \"%s\"\n", current->pattern); printf("\n8 bit: JIT compiler does not support \"%s\"\n", current->pattern);
@ -1375,8 +1376,9 @@ static int regression_tests(void)
else else
length16 = copy_char8_to_char16((PCRE2_SPTR8)current->input, regtest_buf16, REGTEST_MAX_LENGTH16); 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, 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)) { if (pcre2_jit_compile_16(re16, jit_compile_mode)) {
printf("\n16 bit: JIT compiler does not support \"%s\"\n", current->pattern); printf("\n16 bit: JIT compiler does not support \"%s\"\n", current->pattern);
@ -1419,8 +1421,9 @@ static int regression_tests(void)
else else
length32 = copy_char8_to_char32((PCRE2_SPTR8)current->input, regtest_buf32, REGTEST_MAX_LENGTH32); 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, 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)) { if (pcre2_jit_compile_32(re32, jit_compile_mode)) {
printf("\n32 bit: JIT compiler does not support \"%s\"\n", current->pattern); printf("\n32 bit: JIT compiler does not support \"%s\"\n", current->pattern);

13
testdata/testinput15 vendored
View File

@ -46,32 +46,45 @@
/(*LIMIT_DEPTH=4294967280)abc/I /(*LIMIT_DEPTH=4294967280)abc/I
/(a+)*zz/ /(a+)*zz/
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=3000 aaaaaaaaaaaaaz\=match_limit=3000
/(a+)*zz/ /(a+)*zz/
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=10 aaaaaaaaaaaaaz\=depth_limit=10
/(*LIMIT_MATCH=3000)(a+)*zz/I /(*LIMIT_MATCH=3000)(a+)*zz/I
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=60000 aaaaaaaaaaaaaz\=match_limit=60000
/(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I /(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
/(*LIMIT_MATCH=60000)(a+)*zz/I /(*LIMIT_MATCH=60000)(a+)*zz/I
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=3000 aaaaaaaaaaaaaz\=match_limit=3000
/(*LIMIT_DEPTH=10)(a+)*zz/I /(*LIMIT_DEPTH=10)(a+)*zz/I
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=1000 aaaaaaaaaaaaaz\=depth_limit=1000
/(*LIMIT_DEPTH=10)(*LIMIT_DEPTH=1000)(a+)*zz/I /(*LIMIT_DEPTH=10)(*LIMIT_DEPTH=1000)(a+)*zz/I
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
/(*LIMIT_DEPTH=1000)(a+)*zz/I /(*LIMIT_DEPTH=1000)(a+)*zz/I
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=10 aaaaaaaaaaaaaz\=depth_limit=10
# These three have infinitely nested recursions. # These three have infinitely nested recursions.

View File

@ -160,10 +160,13 @@
aaaaaaaaaaaaaz\=match_limit=3000 aaaaaaaaaaaaaz\=match_limit=3000
/(*LIMIT_MATCH=3000)(a+)*zz/I /(*LIMIT_MATCH=3000)(a+)*zz/I
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=60000 aaaaaaaaaaaaaz\=match_limit=60000
/(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I /(*LIMIT_MATCH=60000)(*LIMIT_MATCH=3000)(a+)*zz/I
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
/(*LIMIT_MATCH=60000)(a+)*zz/I /(*LIMIT_MATCH=60000)(a+)*zz/I
@ -175,12 +178,15 @@
# These three have infinitely nested recursions. # These three have infinitely nested recursions.
/((?2))((?1))/ /((?2))((?1))/
\= Expect JIT stack limit reached
abc abc
/((?(R2)a+|(?1)b))()/ /((?(R2)a+|(?1)b))()/
\= Expect JIT stack limit reached
aaaabcde aaaabcde
/(?(R)a*(?1)|((?R))b)/ /(?(R)a*(?1)|((?R))b)/
\= Expect JIT stack limit reached
aaaabcde aaaabcde
# Invalid options disable JIT when called via pcre2_match(), causing the # Invalid options disable JIT when called via pcre2_match(), causing the
@ -277,7 +283,8 @@
/[axm]{7}/ /[axm]{7}/
/(.|.)*?bx/ /(.|.)*?bx/
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax \= Expect limit exceeded
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax\=match_limit=10000000
# Test JIT disable # Test JIT disable

1
testdata/testinput6 vendored
View File

@ -4938,6 +4938,7 @@
abcde\=aftertext 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\x00H]?););?![|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 /(*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\x00H]?););?![|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\x00H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?);); .*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00 \x00\x00\x00H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););
/\n/firstline /\n/firstline

13
testdata/testoutput15 vendored
View File

@ -124,12 +124,15 @@ Last code unit = 'c'
Subject length lower bound = 3 Subject length lower bound = 3
/(a+)*zz/ /(a+)*zz/
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
No match No match
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=3000 aaaaaaaaaaaaaz\=match_limit=3000
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
/(a+)*zz/ /(a+)*zz/
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=10 aaaaaaaaaaaaaz\=depth_limit=10
Failed: error -53: matching depth limit exceeded Failed: error -53: matching depth limit exceeded
@ -139,8 +142,10 @@ Match limit = 3000
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=60000 aaaaaaaaaaaaaz\=match_limit=60000
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
@ -150,6 +155,7 @@ Match limit = 3000
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
@ -159,8 +165,10 @@ Match limit = 60000
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
No match No match
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=3000 aaaaaaaaaaaaaz\=match_limit=3000
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
@ -170,8 +178,10 @@ Depth limit = 10
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
Failed: error -53: matching depth limit exceeded Failed: error -53: matching depth limit exceeded
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=1000 aaaaaaaaaaaaaz\=depth_limit=1000
Failed: error -53: matching depth limit exceeded Failed: error -53: matching depth limit exceeded
@ -181,6 +191,7 @@ Depth limit = 1000
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
No match No match
@ -190,8 +201,10 @@ Depth limit = 1000
Starting code units: a z Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
\= Expect no match
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
No match No match
\= Expect limit exceeded
aaaaaaaaaaaaaz\=depth_limit=10 aaaaaaaaaaaaaz\=depth_limit=10
Failed: error -53: matching depth limit exceeded Failed: error -53: matching depth limit exceeded

View File

@ -300,8 +300,10 @@ Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
JIT compilation was successful JIT compilation was successful
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
\= Expect limit exceeded
aaaaaaaaaaaaaz\=match_limit=60000 aaaaaaaaaaaaaz\=match_limit=60000
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
@ -312,6 +314,7 @@ Starting code units: a z
Last code unit = 'z' Last code unit = 'z'
Subject length lower bound = 2 Subject length lower bound = 2
JIT compilation was successful JIT compilation was successful
\= Expect limit exceeded
aaaaaaaaaaaaaz aaaaaaaaaaaaaz
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
@ -332,14 +335,17 @@ Failed: error -47: match limit exceeded
# These three have infinitely nested recursions. # These three have infinitely nested recursions.
/((?2))((?1))/ /((?2))((?1))/
\= Expect JIT stack limit reached
abc abc
Failed: error -46: JIT stack limit reached Failed: error -46: JIT stack limit reached
/((?(R2)a+|(?1)b))()/ /((?(R2)a+|(?1)b))()/
\= Expect JIT stack limit reached
aaaabcde aaaabcde
Failed: error -46: JIT stack limit reached Failed: error -46: JIT stack limit reached
/(?(R)a*(?1)|((?R))b)/ /(?(R)a*(?1)|((?R))b)/
\= Expect JIT stack limit reached
aaaabcde aaaabcde
Failed: error -46: JIT stack limit reached Failed: error -46: JIT stack limit reached
@ -516,7 +522,8 @@ Failed: error -46: JIT stack limit reached
/[axm]{7}/ /[axm]{7}/
/(.|.)*?bx/ /(.|.)*?bx/
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax \= Expect limit exceeded
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax\=match_limit=10000000
Failed: error -47: match limit exceeded Failed: error -47: match limit exceeded
# Test JIT disable # Test JIT disable

View File

@ -7761,6 +7761,7 @@ No match
0+ 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\x00H]?););?![|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 /(*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\x00H]?););?![|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\x00H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?);); .*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00 \x00\x00\x00H]?););?![|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 Failed: error -47: match limit exceeded