Skip to content

Commit aff71c5

Browse files
committed
PATCH: GH #17371
This was caused by a character being counted as both the first delimiter of a pattern, and the final one, which led to the pattern's length being negative, which was turned into a very large unsigned number.
1 parent 4aada8b commit aff71c5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

regcomp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23332,7 +23332,11 @@ Perl_parse_uniprop_string(pTHX_
2333223332

2333323333
if ( i >= name_len
2333423334
|| name[name_len-1] != close
23335-
|| (escaped && name[name_len-2] != '\\'))
23335+
|| (escaped && name[name_len-2] != '\\')
23336+
/* Also make sure that there are enough characters.
23337+
* e.g., '\\\' would show up incorrectly as legal even
23338+
* though it is too short */
23339+
|| (SSize_t) (name_len - i - 1 - escaped) < 0)
2333623340
{
2333723341
sv_catpvs(msg, "Unicode property wildcard not terminated");
2333823342
goto append_name_to_msg;

t/re/pat.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BEGIN {
2424

2525
skip_all_without_unicode_tables();
2626

27-
plan tests => 1013; # Update this when adding/deleting tests.
27+
plan tests => 1014; # Update this when adding/deleting tests.
2828

2929
run_tests() unless caller;
3030

@@ -2087,6 +2087,9 @@ CODE
20872087
{ # GH #17370, ASAN/valgrind out-of-bounds access
20882088
fresh_perl_like('qr/\p{nv:qnan}/', qr/Can't find Unicode property definition/, {}, "GH #17370");
20892089
}
2090+
{ # GH #17371, segfault
2091+
fresh_perl_like('qr/\p{nv=\\\\\}(?0)|\337ss|\337ss//', qr/Unicode property wildcard not terminated/, {}, "GH #17371");
2092+
}
20902093

20912094
SKIP:
20922095
{ # [perl #133921], segfault

0 commit comments

Comments
 (0)