summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-10-16 22:24:13 -0600
committerKarl Williamson <khw@cpan.org>2014-10-21 09:26:50 -0600
commit5333b64c49d92edaebcba2a634f2cb1d4edc5920 (patch)
tree7cc2096432152ec8ef875c0ac936a06b579caaa9 /toke.c
parentaae773bbd74e39596c3ed0ed403f36b245b6d687 (diff)
downloadperl-5333b64c49d92edaebcba2a634f2cb1d4edc5920.tar.gz
toke.c: Fix potential buffer overflow
Malformed UTF-8 input could have potentially caused a read off the end of the buffer here until this commit.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index 44d0fefdf4..7fd43cf7ed 100644
--- a/toke.c
+++ b/toke.c
@@ -8564,7 +8564,9 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)
|| (((U8)(d)) <= 8 && (d) != 0) \
|| (((U8)(d)) == 13)))) \
|| (((U8)(d)) == toCTRL('?')))
- if (s < PL_bufend
+ if ((s <= PL_bufend - (is_utf8)
+ ? UTF8SKIP(s)
+ : 1)
&& (isIDFIRST_lazy_if(s, is_utf8) || VALID_LEN_ONE_IDENT(*s, is_utf8)))
{
if ( isCNTRL_A((U8)*s) ) {