diff options
author | David Mitchell <davem@iabyn.com> | 2010-06-22 17:03:12 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-07-03 16:25:58 +0100 |
commit | a02ec77af3235fc3d744725d93fbef7d9126695a (patch) | |
tree | 4db33cf47ccd836490de9f68821eb15f31483096 /sv.c | |
parent | 3340ac375f37f424a40787ccf00c582048903d8d (diff) | |
download | perl-a02ec77af3235fc3d744725d93fbef7d9126695a.tar.gz |
fix tainting and overload
Sometimes when an overload method returned a tainted value, that
taintedness got lost. This fixes #75716: overload removes tainting.
It also considerably expands the tied series of tests in overload.t.
It now taints the return value, and checks for correct taintedness.
It also tests against two overload packages: the new one only has fallback
methods, which affects the return path for the tainted value.
It now also compares the expected (non-tied, non-overload) expression
value against a overloaded version of that expression in addition to
versions where a tied var returned an overloaded object; e.g. in these
expressions:
1: 1 + $plain_value
2: 1 + $overloaded_var
3: 1 + $tied_scalar_that_returns_overloaded_value
4: 1 + $tied_array_whose element_0_holds_an_overloaded_value[0]
then the value of expression 1 is compared against each of 2,3,4, whereas
before it was only compared against 3,4.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -2683,6 +2683,7 @@ Perl_sv_2num(pTHX_ register SV *const sv) return sv; if (SvAMAGIC(sv)) { SV * const tmpsv = AMG_CALLun(sv,numer); + TAINT_IF(tmpsv && SvTAINTED(tmpsv)); if (tmpsv && (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv)))) return sv_2num(tmpsv); } @@ -2804,6 +2805,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags if (flags & SV_SKIP_OVERLOAD) return NULL; tmpstr = AMG_CALLun(sv,string); + TAINT_IF(tmpstr && SvTAINTED(tmpstr)); if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { /* Unwrap this: */ /* char *pv = lp ? SvPV(tmpstr, *lp) : SvPV_nolen(tmpstr); |