Fix PCRE2_NO_AUTO_CAPTURE bug.

This commit is contained in:
Philip.Hazel 2015-10-25 17:35:34 +00:00
parent 8a8d0ced69
commit 766fbc81d0
4 changed files with 27 additions and 12 deletions

View File

@ -213,6 +213,10 @@ and AddressSanitizer.
61. Whitespace at the end of a pcre2test pattern line caused a spurious error 61. Whitespace at the end of a pcre2test pattern line caused a spurious error
message if there were only single-character modifiers. It should be ignored. message if there were only single-character modifiers. It should be ignored.
62. The use of PCRE2_NO_AUTO_CAPTURE could cause incorrect compilation results
or segmentation errors for some patterns. Found with libFuzzer and
AddressSanitizer.
Version 10.20 30-June-2015 Version 10.20 30-June-2015
-------------------------- --------------------------

View File

@ -3187,9 +3187,10 @@ for (; ptr < cb->end_pattern; ptr++)
if (ptr[1] != CHAR_QUESTION_MARK) if (ptr[1] != CHAR_QUESTION_MARK)
{ {
if (ptr[1] != CHAR_ASTERISK && if (ptr[1] != CHAR_ASTERISK)
(options & PCRE2_NO_AUTO_CAPTURE) == 0) {
cb->bracount++; /* Capturing group */ if ((options & PCRE2_NO_AUTO_CAPTURE) == 0) cb->bracount++;
}
else /* (*something) - just skip to closing ket */ else /* (*something) - just skip to closing ket */
{ {
ptr += 2; ptr += 2;

4
testdata/testinput2 vendored
View File

@ -4583,4 +4583,8 @@ B)x/alt_verbnames,mark
/^(o(\1{72}{\"{\\{00000059079}\d*){74}}){19}/I /^(o(\1{72}{\"{\\{00000059079}\d*){74}}){19}/I
/((p(?'K/
/((p(?'K/no_auto_capture
# End of testinput2 # End of testinput2

View File

@ -14668,4 +14668,10 @@ Overall options: anchored
Last code unit = '}' Last code unit = '}'
Subject length lower bound = 65535 Subject length lower bound = 65535
/((p(?'K/
Failed: error 142 at offset 7: syntax error in subpattern name (missing terminator)
/((p(?'K/no_auto_capture
Failed: error 142 at offset 7: syntax error in subpattern name (missing terminator)
# End of testinput2 # End of testinput2