From 63cab0dba95b9a03e392dcd70017ca792f0c8d3a Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Sun, 29 Mar 2015 15:40:45 +0000 Subject: [PATCH] Fix non-diagnosis of syntax error for (?(?< when not followed by ! or =. --- ChangeLog | 5 +++++ src/pcre2_compile.c | 4 +++- testdata/testinput2 | 4 ++++ testdata/testoutput2 | 7 ++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a4c838..619029f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,6 +45,11 @@ discovered by the LLVM fuzzer. between a subroutine call and its quantifier was incorrectly compiled, leading to buffer overflow or other errors. This bug was discovered by the LLVM fuzzer. +12. The illegal pattern /(?(?.*!.*)?)/ was not being diagnosed as missing an +assertion after (?(. The code was failing to check the character after (?(?< +for the ! or = that would indicate a lookbehind assertion. This bug was +discovered by the LLVM fuzzer. + Version 10.10 06-March-2015 --------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 92c204d..b349900 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -5272,7 +5272,9 @@ for (;; ptr++) if (tempptr[1] == CHAR_QUESTION_MARK && (tempptr[2] == CHAR_EQUALS_SIGN || tempptr[2] == CHAR_EXCLAMATION_MARK || - tempptr[2] == CHAR_LESS_THAN_SIGN)) + (tempptr[2] == CHAR_LESS_THAN_SIGN && + (tempptr[3] == CHAR_EQUALS_SIGN || + tempptr[3] == CHAR_EXCLAMATION_MARK)))) { cb->iscondassert = TRUE; break; diff --git a/testdata/testinput2 b/testdata/testinput2 index 2acfcca..5c26c1f 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4241,4 +4241,8 @@ a random value. /Ix "(*NO_JIT)((?2)+)((?1)){" abcd{ +# Perl fails to diagnose the absence of an assertion + +"(?(?.*!.*)?)" + # End of testinput2 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 65e7605..1c6829f 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -573,7 +573,7 @@ Failed: error 128 at offset 3: assertion expected after (?( or (?(?C) Failed: error 115 at offset 7: reference to non-existent subpattern /(?(?.*!.*)?)" +Failed: error 128 at offset 3: assertion expected after (?( or (?(?C) + # End of testinput2