summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-22 09:29:19 -0700
committerKarl Williamson <khw@cpan.org>2020-01-23 15:46:56 -0700
commite38c22ba7692da6fe924cec30ea91e1cdfe2e13a (patch)
tree7277f9b98da597853f83093c9b0b4cb3bcf02566 /toke.c
parentfb2f0a6ac56afb1c2b30b73112442b1eea989f24 (diff)
downloadperl-e38c22ba7692da6fe924cec30ea91e1cdfe2e13a.tar.gz
toke.c: Don't accept illegal code points
This now croaks if the input is an illegal code point. Before, it likely would eventually croak if that code point was actually used in some manner.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index abdd36d67f..4f90f17972 100644
--- a/toke.c
+++ b/toke.c
@@ -3747,13 +3747,23 @@ S_scan_const(pTHX_ char *start)
}
else { /* Not a pattern: convert the hex to string */
I32 flags = PERL_SCAN_ALLOW_UNDERSCORES
- | PERL_SCAN_SILENT_ILLDIGIT
- | PERL_SCAN_DISALLOW_PREFIX;
+ | PERL_SCAN_SILENT_ILLDIGIT
+ | PERL_SCAN_SILENT_OVERFLOW
+ | PERL_SCAN_DISALLOW_PREFIX;
STRLEN len = e - s;
+
uv = grok_hex(s, &len, &flags, NULL);
if (len == 0 || (len != (STRLEN)(e - s)))
goto bad_NU;
+ if ( uv > MAX_LEGAL_CP
+ || (flags & PERL_SCAN_GREATER_THAN_UV_MAX))
+ {
+ yyerror(form_cp_too_large_msg(16, s, len, 0));
+ uv = 0; /* drop through to ensure range ends are
+ set */
+ }
+
/* For non-tr///, if the destination is not in utf8,
* unconditionally recode it to be so. This is
* because \N{} implies Unicode semantics, and scalars