Fix mutual recursion inside other parentheses stack overflow bug.

This commit is contained in:
ph10 2015-03-27 17:45:02 +00:00
parent 625fd31e3e
commit 1a1781e0c9
4 changed files with 17 additions and 2 deletions

View File

@ -37,6 +37,10 @@ interacting badly with the code for computing the amount of space needed to
compile the pattern, leading to a buffer overflow. This bug was discovered by
the LLVM fuzzer.
10. A pattern such as /((?2)+)((?1))/ which has mutual recursion nested inside
other kinds of group caused stack overflow at compile time. This bug was
discovered by the LLVM fuzzer.
Version 10.10 06-March-2015
---------------------------

View File

@ -1331,8 +1331,8 @@ for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
empty_branch = FALSE;
do
{
if (!empty_branch && could_be_empty_branch(code, endcode, utf, cb, NULL))
empty_branch = TRUE;
if (!empty_branch && could_be_empty_branch(code, endcode, utf, cb,
recurses)) empty_branch = TRUE;
code += GET(code, 1);
}
while (*code == OP_ALT);

5
testdata/testinput2 vendored
View File

@ -4236,4 +4236,9 @@ a random value. /Ix
** Failers
aaa
# JIT gives a different error message for the infinite recursion
"(*NO_JIT)((?2)+)((?1)){"
abcd{
# End of testinput2

View File

@ -14198,4 +14198,10 @@ No match
aaa
No match
# JIT gives a different error message for the infinite recursion
"(*NO_JIT)((?2)+)((?1)){"
abcd{
Failed: error -52: nested recursion at the same subject position
# End of testinput2