forked from Perl/perl5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sv_gets: use a SSize_t append character index
This used an I32, which could overflow when reading from a large source. https://www.perlmonks.org/?node_id=11161665
- Loading branch information
Showing
5 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!perl | ||
BEGIN { | ||
chdir 't' if -d 't'; | ||
@INC = "../lib"; | ||
} | ||
|
||
use strict; | ||
require './test.pl'; | ||
use Config qw(%Config); | ||
|
||
# 2 for the child, 2 for the parent | ||
$ENV{PERL_TEST_MEMORY} >= 4 | ||
or skip_all("Need ~4Gb for this test"); | ||
$Config{ptrsize} >= 8 | ||
or skip_all("Need 64-bit pointers for this test"); | ||
|
||
{ | ||
# https://www.perlmonks.org/?node_id=11161665 | ||
my $x = `$^X -e "print q/x/ x 0x80000000"`; | ||
is(length $x, 0x80000000, "check entire input read"); | ||
undef $x; | ||
} | ||
|
||
{ | ||
# sv_gets_append_to_utf8 append parameter | ||
my $x = "x"; | ||
$x x= 0x8000_0000; | ||
utf8::upgrade($x); | ||
# using bareword handle because the rcatline optimization isn't done | ||
# for non-barewords | ||
# for $fh | ||
# we chdired to "t" | ||
open FH, "<", "TEST" or die $!; | ||
$x .= <FH>; | ||
pass("didn't crash appending readline to large upgraded scalar"); | ||
} | ||
|
||
{ | ||
# sv_gets_read_record append parameter | ||
my $x = "x"; | ||
$x x= 0x8000_0000; | ||
open FH, "<", "TEST" or die $!; | ||
local $/ = \100; | ||
$x .= <FH>; | ||
pass("didn't crash appending readline recoed to large scalar"); | ||
} | ||
|
||
done_testing(); |