Skip to content

Commit 81d1145

Browse files
committed
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.
1 parent 5162664 commit 81d1145

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

numeric.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ Perl_grok_infnan(pTHX_ const char** sp, const char* send)
791791
/* "nanq" or "nans" are ok, though generating
792792
* these portably is tricky. */
793793
s++;
794+
if (s == send) {
795+
return flags;
796+
}
794797
}
795798
if (*s == '(') {
796799
/* C99 style "nan(123)" or Perlish equivalent "nan($uv)". */

t/re/pat.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BEGIN {
2424

2525
skip_all_without_unicode_tables();
2626

27-
plan tests => 1011; # Update this when adding/deleting tests.
27+
plan tests => 1012; # Update this when adding/deleting tests.
2828

2929
run_tests() unless caller;
3030

@@ -2081,6 +2081,10 @@ CODE
20812081
{ # [perl #133871], ASAN/valgrind out-of-bounds access
20822082
fresh_perl_like('qr/(?|(())|())|//', qr/syntax error/, {}, "[perl #133871]");
20832083
}
2084+
{ # [perl #133871], ASAN/valgrind out-of-bounds access
2085+
fresh_perl_like('qr/\p{nv:NAnq}/', qr/Can't find Unicode property definition/, {}, "GH #17367");
2086+
}
2087+
20842088
SKIP:
20852089
{ # [perl #133921], segfault
20862090
skip "Not valid for EBCDIC", 5 if $::IS_EBCDIC;

0 commit comments

Comments
 (0)