Skip to content

Commit 92be2d3

Browse files
khwilliamsonsteve-m-hay
authored andcommitted
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. (cherry picked from commit 81d1145)
1 parent b7b8b09 commit 92be2d3

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
@@ -776,6 +776,9 @@ Perl_grok_infnan(pTHX_ const char** sp, const char* send)
776776
/* "nanq" or "nans" are ok, though generating
777777
* these portably is tricky. */
778778
s++;
779+
if (s == send) {
780+
return flags;
781+
}
779782
}
780783
if (*s == '(') {
781784
/* 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
@@ -25,7 +25,7 @@ BEGIN {
2525
skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
2626
skip_all_without_unicode_tables();
2727

28-
plan tests => 865; # Update this when adding/deleting tests.
28+
plan tests => 866; # Update this when adding/deleting tests.
2929

3030
run_tests() unless caller;
3131

@@ -2006,6 +2006,10 @@ CODE
20062006
{ # [perl #133871], ASAN/valgrind out-of-bounds access
20072007
fresh_perl_like('qr/(?|(())|())|//', qr/syntax error/, {}, "[perl #133871]");
20082008
}
2009+
{ # [perl #133871], ASAN/valgrind out-of-bounds access
2010+
fresh_perl_like('qr/\p{nv:NAnq}/', qr/Can't find Unicode property definition/, {}, "GH #17367");
2011+
}
2012+
20092013
{ # [perl #133921], segfault
20102014
fresh_perl_is('qr0||ß+p00000F00000ù\Q00000ÿ00000x00000x0c0e0\Qx0\Qx0\x{0c!}\;\;î0\xÿÿÿþù\Q`\Qx`{0c!}e;ù\ò`\Qm`\x{0c!}\;\;îçÿ ç!F/;îçÿù\Qxÿÿÿÿù`x{0c!}e;ù\Q`\Qx`\x{c!}\;\;îç!}\;îçÿù\Q‡ \xÿÿÿÿ>=\Qx`\Qx`ù\ò`\Qx`\x{0c!};\;îçÿ Fn0t0c €d;t ù ç€!00000000000000000000000m/0000000000000000000000000000000m/\x{){} )|i', "", {}, "[perl #133921]");
20112015
fresh_perl_is('|ß+W0ü0r0\Qx0\Qx0x0c0G00000000000000000O000000000x0x0x0c!}\;îçÿù\Q0 \xÿÿÿÿù\Q`\Qx`{0d ;ù\ò`\Qm`\x{0c!}\;\;îçÿ ç!F/;îçÿù\Qxÿÿÿÿù`x{0c!};ù\Q`\Qq`\x{c!}\;\;îç!}\;îçÿù\Q‡ \xÿÿÿÿ>=\Qx`\Qx`ù\ò`\Qx`\x{0c!};\;îçÿ 0000000Fm0t0c €d;t ù ç€!00000000000000000000000m/0000000000000000000000000000000m/\x{){} )|i', "", {}, "[perl #133921]");

0 commit comments

Comments
 (0)