This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Replace infinite loop reading input by bounded
authorKarl Williamson <khw@cpan.org>
Tue, 13 Dec 2016 02:42:23 +0000 (19:42 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 23 Dec 2016 23:48:35 +0000 (16:48 -0700)
It's safer to have an upper limit on how far you look in your input.

toke.c

diff --git a/toke.c b/toke.c
index 09fcddc..489e772 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -8987,7 +8987,7 @@ S_parse_ident(pTHX_ char **s, char **d, char * const e, int allow_package,
 {
     PERL_ARGS_ASSERT_PARSE_IDENT;
 
-    for (;;) {
+    while (*s < PL_bufend) {
         if (*d >= e)
             Perl_croak(aTHX_ "%s", ident_too_long);
         if (is_utf8 && isIDFIRST_utf8_safe(*s, PL_bufend)) {