In gv_autoload4(), ensure set magic is called on $...::AUTOLOAD if necessary.
authorNicholas Clark <nick@ccl4.org>
Sun, 27 Feb 2011 21:36:01 +0000 (21:36 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 27 Feb 2011 21:39:08 +0000 (21:39 +0000)
Without this, if $...::AUTOLOAD ever becomes tainted, it will never
subsequently become properly untainted. This fixes an omission in change
5d121f7f3e622b95.

gv.c
t/op/taint.t

diff --git a/gv.c b/gv.c
index f417686..96301ff 100644 (file)
--- 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;
 }
 
index a040e46..7e82d1e 100644 (file)
@@ -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;
 }