From d90de8b053fac0671b6d89c02d9a51c6de059716 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Thu, 7 Feb 2019 17:59:37 +0000 Subject: [PATCH] Previout bug-fix was bad. This properly fixes an overrun while reading a Unicode group name. --- src/pcre2_compile.c | 2 +- testdata/testinput10 | 4 ++++ testdata/testinput12 | 4 ++++ testdata/testoutput10 | 6 ++++++ testdata/testoutput12-16 | 6 ++++++ testdata/testoutput12-32 | 6 ++++++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 266d321..d72d9bd 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -2246,8 +2246,8 @@ if (utf && is_group) if (type != ucp_Nd && PRIV(ucp_gentype)[type] != ucp_L && c != CHAR_UNDERSCORE) break; ptr++; + FORWARDCHARTEST(ptr, ptrend); if (ptr >= ptrend) break; - FORWARDCHAR(ptr); GETCHAR(c, ptr); type = UCD_CHARTYPE(c); } diff --git a/testdata/testinput10 b/testdata/testinput10 index 50e489f..4399f82 100644 --- a/testdata/testinput10 +++ b/testdata/testinput10 @@ -489,4 +489,8 @@ /(?'ABZC6789012345678901234567890123'...)/utf +/(?(n/utf + +/(?(á/utf + # End of testinput10 diff --git a/testdata/testinput12 b/testdata/testinput12 index 29d1095..466fb93 100644 --- a/testdata/testinput12 +++ b/testdata/testinput12 @@ -398,4 +398,8 @@ \x{2e80}\x{3105}\x{2e80}\x{30a1} Han Bopomofo Han Katakana \x{d800}\x{dfff} Surrogates (Unknown) \=no_utf_check +/(?(n/utf + +/(?(á/utf + # End of testinput12 diff --git a/testdata/testoutput10 b/testdata/testoutput10 index 724b8bc..dfecda1 100644 --- a/testdata/testoutput10 +++ b/testdata/testoutput10 @@ -1645,4 +1645,10 @@ Failed: error 148 at offset 36: subpattern name is too long (maximum 32 code uni /(?'ABZC6789012345678901234567890123'...)/utf +/(?(n/utf +Failed: error 142 at offset 4: syntax error in subpattern name (missing terminator?) + +/(?(á/utf +Failed: error 142 at offset 5: syntax error in subpattern name (missing terminator?) + # End of testinput10 diff --git a/testdata/testoutput12-16 b/testdata/testoutput12-16 index 09151b4..3f2c91f 100644 --- a/testdata/testoutput12-16 +++ b/testdata/testoutput12-16 @@ -1496,4 +1496,10 @@ Failed: error 191 at offset 0: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowe \x{2e80}\x{3105}\x{2e80}\x{30a1} Han Bopomofo Han Katakana \x{d800}\x{dfff} Surrogates (Unknown) \=no_utf_check +/(?(n/utf +Failed: error 142 at offset 4: syntax error in subpattern name (missing terminator?) + +/(?(á/utf +Failed: error 142 at offset 4: syntax error in subpattern name (missing terminator?) + # End of testinput12 diff --git a/testdata/testoutput12-32 b/testdata/testoutput12-32 index ea70896..cb90190 100644 --- a/testdata/testoutput12-32 +++ b/testdata/testoutput12-32 @@ -1494,4 +1494,10 @@ No match \x{d800}\x{dfff} Surrogates (Unknown) \=no_utf_check 0: \x{d800} +/(?(n/utf +Failed: error 142 at offset 4: syntax error in subpattern name (missing terminator?) + +/(?(á/utf +Failed: error 142 at offset 4: syntax error in subpattern name (missing terminator?) + # End of testinput12