diff options
author | David Mitchell <davem@iabyn.com> | 2017-03-15 14:35:59 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-03-17 14:13:40 +0000 |
commit | d69c43040e4967294b1195ecfdc4acf0f74b5958 (patch) | |
tree | 239ab78aa25726bed3e85e66a6a9e6677d5102f9 /proto.h | |
parent | 7e337d2de5bfdccdeeb8d3f2f24f559ff905770a (diff) | |
download | perl-d69c43040e4967294b1195ecfdc4acf0f74b5958.tar.gz |
Perl_do_vecget(): change offset arg to STRLEN type
... and fix up its caller, pp_vec().
This is part of a fix for RT #130915.
pp_vec() is responsible for extracting out the offset and size from SVs on
the stack, and then calling do_vecget() with those values. (Sometimes the
call is done indirectly by storing the offset in the LvTARGOFF() field of
a SVt_PVLV, then later Perl_magic_getvec() passes the LvTARGOFF() value to
do_vecget().)
Now SvCUR, SvLEN and LvTARGOFF are all of type STRLEN (a.k.a Size_t),
while the offset arg of do_vecget() is of type SSize_t (i.e. there's a
signed/unsigned mismatch). It makes more sense to make the arg of type
STRLEN. So that is what this commit does.
At the same time this commit fixes up pp_vec() to handle all the
possibilities where the offset value can't fit into a STRLEN, returning 0
or croaking accordingly, so that do_vecget() is never called with a
truncated or wrapped offset.
The next commit will fix up the internals of do_vecget() and do_vecset(),
which have to worry about offset*(2^n) wrapping or being > SvCUR().
This commit is based on an earlier proposed fix by Aaron Crane.
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -806,7 +806,7 @@ PERL_CALLCONV Off_t Perl_do_tell(pTHX_ GV* gv) PERL_CALLCONV I32 Perl_do_trans(pTHX_ SV* sv); #define PERL_ARGS_ASSERT_DO_TRANS \ assert(sv) -PERL_CALLCONV UV Perl_do_vecget(pTHX_ SV* sv, SSize_t offset, int size); +PERL_CALLCONV UV Perl_do_vecget(pTHX_ SV* sv, STRLEN offset, int size); #define PERL_ARGS_ASSERT_DO_VECGET \ assert(sv) PERL_CALLCONV void Perl_do_vecset(pTHX_ SV* sv); |