summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-11-13 15:39:15 -0700
committerKarl Williamson <khw@cpan.org>2019-12-17 11:19:31 -0700
commit81d11450691ee281f37c6c4e8055735b972733bd (patch)
treea5ae0ca505516b3e391102045ab799a32e5d2116
parent5162664ad5f98a91d900af385de396cff1a34d47 (diff)
downloadperl-81d11450691ee281f37c6c4e8055735b972733bd.tar.gz
PATCH: GH #17367 read 1 beyond end of buffer
This is a bug in grok_infnan() in which in one place it failed to check that it was reading within bounds.
-rw-r--r--numeric.c3
-rw-r--r--t/re/pat.t6
2 files changed, 8 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index db8197c259..142f61753a 100644
--- a/numeric.c
+++ b/numeric.c
@@ -791,6 +791,9 @@ Perl_grok_infnan(pTHX_ const char** sp, const char* send)
/* "nanq" or "nans" are ok, though generating
* these portably is tricky. */
s++;
+ if (s == send) {
+ return flags;
+ }
}
if (*s == '(') {
/* C99 style "nan(123)" or Perlish equivalent "nan($uv)". */
diff --git a/t/re/pat.t b/t/re/pat.t
index 8045ed43fd..413fbee823 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -24,7 +24,7 @@ BEGIN {
skip_all_without_unicode_tables();
-plan tests => 1011; # Update this when adding/deleting tests.
+plan tests => 1012; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -2081,6 +2081,10 @@ CODE
{ # [perl #133871], ASAN/valgrind out-of-bounds access
fresh_perl_like('qr/(?|(())|())|//', qr/syntax error/, {}, "[perl #133871]");
}
+ { # [perl #133871], ASAN/valgrind out-of-bounds access
+ fresh_perl_like('qr/\p{nv:NAnq}/', qr/Can't find Unicode property definition/, {}, "GH #17367");
+ }
+
SKIP:
{ # [perl #133921], segfault
skip "Not valid for EBCDIC", 5 if $::IS_EBCDIC;