diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-11-27 05:40:53 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-11-27 07:41:47 -0800 |
commit | ab9f15865f0bdb3a056da035e63d3297f7c6f3c8 (patch) | |
tree | 544ca6317b4602bec18507709b88cdeaad7510dd /ext/PerlIO-scalar | |
parent | 6a8c86944bc507200cc01e245d39300e2e6ab775 (diff) | |
download | perl-ab9f15865f0bdb3a056da035e63d3297f7c6f3c8.tar.gz |
[perl #78716] Bogus read after seek beyond end of string
This is a signedness problem that ffe0bb5ab did not take into account.
(STRLEN)-10 > 0 returns true for me.
Diffstat (limited to 'ext/PerlIO-scalar')
-rw-r--r-- | ext/PerlIO-scalar/scalar.xs | 3 | ||||
-rw-r--r-- | ext/PerlIO-scalar/t/scalar.t | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs index b93b9e9257..6fe551d34c 100644 --- a/ext/PerlIO-scalar/scalar.xs +++ b/ext/PerlIO-scalar/scalar.xs @@ -150,7 +150,8 @@ PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count) PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar); SV *sv = s->var; char *p; - STRLEN len, got; + STRLEN len; + I32 got; p = SvPV(sv, len); got = len - (STRLEN)(s->posn); if (got <= 0) diff --git a/ext/PerlIO-scalar/t/scalar.t b/ext/PerlIO-scalar/t/scalar.t index adc5b8ef89..1aee4b0e67 100644 --- a/ext/PerlIO-scalar/t/scalar.t +++ b/ext/PerlIO-scalar/t/scalar.t @@ -16,7 +16,7 @@ use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere. $| = 1; -use Test::More tests => 69; +use Test::More tests => 70; my $fh; my $var = "aaa\n"; @@ -276,4 +276,11 @@ EOF is($s, ':F:S(GHI):O:F:R:F:R:F:R', 'tied actions - read'); } - +# [perl #78716] Seeking beyond the end of the string, then reading +{ + my $str = '1234567890'; + open my $strIn, '<', \$str; + seek $strIn, 15, 1; + is read($strIn, my $buffer, 5), 0, + 'seek beyond end end of string followed by read'; +} |