Revision: 1138
http://www.exim.org/viewvc/pcre2?view=rev&revision=1138
Author: ph10
Date: 2019-07-18 18:20:29 +0100 (Thu, 18 Jul 2019)
Log Message:
-----------
Fix bug in recent patch for lookbehinds within lookaheads. Fixes ClusterFuzz
15933.
Modified Paths:
--------------
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2019-07-18 06:11:04 UTC (rev 1137)
+++ code/trunk/src/pcre2_compile.c 2019-07-18 17:20:29 UTC (rev 1138)
@@ -136,7 +136,8 @@
parsed_recurse_check *, compile_block *);
static int
- check_lookbehinds(uint32_t *, uint32_t **, compile_block *);
+ check_lookbehinds(uint32_t *, uint32_t **, parsed_recurse_check *,
+ compile_block *);
/*************************************************
@@ -9116,7 +9117,7 @@
case META_LOOKAHEAD:
case META_LOOKAHEADNOT:
case META_LOOKAHEAD_NA:
- *errcodeptr = check_lookbehinds(pptr + 1, &pptr, cb);
+ *errcodeptr = check_lookbehinds(pptr + 1, &pptr, recurses, cb);
if (*errcodeptr != 0) return -1;
/* Ignore any qualifiers that follow a lookahead assertion. */
@@ -9461,15 +9462,17 @@
non-nested closing parenthesis in this case, returning a pointer to it.
Arguments
- pptr points to where to start (start of pattern or start of lookahead)
- retptr if not NULL, return the ket pointer here
- cb points to the compile block
+ pptr points to where to start (start of pattern or start of lookahead)
+ retptr if not NULL, return the ket pointer here
+ recurses chain of recurse_check to catch mutual recursion
+ cb points to the compile block
-Returns: 0 on success, or an errorcode (cb->erroroffset will be set)
+Returns: 0 on success, or an errorcode (cb->erroroffset will be set)
*/
static int
-check_lookbehinds(uint32_t *pptr, uint32_t **retptr, compile_block *cb)
+check_lookbehinds(uint32_t *pptr, uint32_t **retptr,
+ parsed_recurse_check *recurses, compile_block *cb)
{
int max;
int errorcode = 0;
@@ -9587,7 +9590,8 @@
case META_LOOKBEHIND:
case META_LOOKBEHINDNOT:
case META_LOOKBEHIND_NA:
- if (!set_lookbehind_lengths(&pptr, &max, &errorcode, &loopcount, NULL, cb))
+ if (!set_lookbehind_lengths(&pptr, &max, &errorcode, &loopcount,
+ recurses, cb))
return errorcode;
break;
}
@@ -10041,7 +10045,7 @@
if (has_lookbehind)
{
- errorcode = check_lookbehinds(cb.parsed_pattern, NULL, &cb);
+ errorcode = check_lookbehinds(cb.parsed_pattern, NULL, NULL, &cb);
if (errorcode != 0) goto HAD_CB_ERROR;
}
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2019-07-18 06:11:04 UTC (rev 1137)
+++ code/trunk/testdata/testinput2 2019-07-18 17:20:29 UTC (rev 1138)
@@ -5693,4 +5693,7 @@
/(?<=(?=.(?<=x)))/
ab\=ph
+# Expect error (recursion => not fixed length)
+/(\2)((?=(?<=\1)))/
+
# End of testinput2
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2019-07-18 06:11:04 UTC (rev 1137)
+++ code/trunk/testdata/testoutput2 2019-07-18 17:20:29 UTC (rev 1138)
@@ -17189,6 +17189,10 @@
ab\=ph
No match
+# Expect error (recursion => not fixed length)
+/(\2)((?=(?<=\1)))/
+Failed: error 125 at offset 8: lookbehind assertion is not fixed length
+
# End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data