From: Nicholas Clark Date: Sun, 27 Feb 2011 21:36:01 +0000 (+0000) Subject: In gv_autoload4(), ensure set magic is called on $...::AUTOLOAD if necessary. X-Git-Tag: accepted/trunk/20130322.191538~5275 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d40bf27b2d1479df2acf7e7f9b7b96eae0451649;p=platform%2Fupstream%2Fperl.git In gv_autoload4(), ensure set magic is called on $...::AUTOLOAD if necessary. Without this, if $...::AUTOLOAD ever becomes tainted, it will never subsequently become properly untainted. This fixes an omission in change 5d121f7f3e622b95. --- diff --git a/gv.c b/gv.c index f417686..96301ff 100644 --- a/gv.c +++ b/gv.c @@ -852,7 +852,9 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) varsv = GvSVn(vargv); sv_setpvn(varsv, packname, packname_len); sv_catpvs(varsv, "::"); - sv_catpvn(varsv, name, len); + /* Ensure SvSETMAGIC() is called if necessary. In particular, to clear + tainting if $FOO::AUTOLOAD was previously tainted, but is not now. */ + sv_catpvn_mg(varsv, name, len); return gv; } diff --git a/t/op/taint.t b/t/op/taint.t index a040e46..7e82d1e 100644 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -17,7 +17,7 @@ use Config; use File::Spec::Functions; BEGIN { require './test.pl'; } -plan tests => 689; +plan tests => 693; $| = 1; @@ -1888,13 +1888,18 @@ SKIP: return if $AUTOLOAD =~ /DESTROY/; if ($AUTOLOAD =~ /untainted/) { main::ok(!main::tainted($AUTOLOAD), '$AUTOLOAD can be untainted'); + my $copy = $AUTOLOAD; + main::ok(!main::tainted($copy), '$AUTOLOAD can be untainted'); } else { main::ok(main::tainted($AUTOLOAD), '$AUTOLOAD can be tainted'); + my $copy = $AUTOLOAD; + main::ok(main::tainted($copy), '$AUTOLOAD can be tainted'); } } package main; my $o = bless [], 'AUTOLOAD_TAINT'; + $o->untainted; $o->$TAINT; $o->untainted; }