diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-22 09:29:19 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-01-23 15:46:56 -0700 |
commit | e38c22ba7692da6fe924cec30ea91e1cdfe2e13a (patch) | |
tree | 7277f9b98da597853f83093c9b0b4cb3bcf02566 /toke.c | |
parent | fb2f0a6ac56afb1c2b30b73112442b1eea989f24 (diff) | |
download | perl-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.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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 |