-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s//$obj/ does not propagated taintedness of overloaded object #12495
Comments
From @cpansproutThis little bit of code in pp_ctl.c:pp_substcont seemed suspicious: SvGETMAGIC(TOPs); /* possibly clear taint on $1 etc: #67962 */ /* See "how taint works" above pp_subst() */ So I tried testing it, and, indeed, taintedness is not propagated: package o { use overload '""' => sub { $^X } } bless $o=[],o; I thought this would fix it, but it does not: Inline Patchdiff --git a/pp_ctl.c b/pp_ctl.c
index 23847c4..5bb4901 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -203,12 +203,10 @@ PP(pp_substcont)
if (cx->sb_iters > cx->sb_maxiters)
DIE(aTHX_ "Substitution loop");
- SvGETMAGIC(TOPs); /* possibly clear taint on $1 etc: #67962 */
-
+ sv_catsv(dstr, POPs);
/* See "how taint works" above pp_subst() */
- if (SvTAINTED(TOPs))
+ if (SvTAINTED(TOPp1s))
cx->sb_rxtainted |= SUBST_TAINT_REPL;
- sv_catsv_nomg(dstr, POPs);
/* XXX: adjust for positive offsets of \G for instance s/(.)\G//g with positive pos() */
s -= RX_GOFS(rx);
diff --git a/t/op/taint.t b/t/op/taint.t
index d621de6..69c0832 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
use strict;
use Config;
-plan tests => 797;
+plan tests => 805;
$| = 1;
@@ -579,6 +579,17 @@ my $TEST = 'TEST';
is($res, 'xyz', "$desc: res value");
is($one, 'abcd', "$desc: \$1 value");
+ $desc = 's//complex expr returning overload obj that taints on ""/e';
+
+ package o { use overload '""' => sub { $TAINT } }
+ bless my $o = [], o::;
+ $s = 'hello';
+ $res = $s =~ s/h/($o)[0]/e;
+ is_tainted($s, "$desc: s tainted");
+ isnt_tainted($res, "$desc: res not tainted");
+ is($s, 'ello', "$desc: s value");
+ is($res, '1', "$desc: res value");
+
{
# now do them all again with "use re 'taint"
@@ -935,6 +946,17 @@ my $TEST = 'TEST';
is($s, 'abcd', "$desc: s value");
is($res, 'xyz', "$desc: res value");
is($one, 'abcd', "$desc: \$1 value");
+
+ $desc = 'use re "taint": s//complex expr returning overload obj '
+ .'that taints on ""/e';
+
+ bless my $o = [], o::;
+ $s = 'hello';
+ $res = $s =~ s/h/($o)[0]/e;
+ is_tainted($s, "$desc: s tainted");
+ isnt_tainted($res, "$desc: res not tainted");
+ is($s, 'ello', "$desc: s value");
+ is($res, '1', "$desc: res value");
}
$foo = $1 if 'bar' =~ /(.+)$TAINT/;
---
Site configuration information for perl 5.17.5: Configured by sprout at Sat Sep 22 18:51:23 PDT 2012. Summary of my perl5 (revision 5 version 17 subversion 5) configuration: Locally applied patches: @INC for perl 5.17.5: Environment for perl 5.17.5: |
From zefram@fysh.orgFixed in commit c4f4b22. -zefram |
The RT System itself - Status changed from 'new' to 'open' |
@xsawyerx - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#115266 (status was 'resolved')
Searchable as RT115266$
The text was updated successfully, but these errors were encountered: