On Tue, Jul 05, 2005 at 02:42:59AM +0100, Dave Mitchell wrote:
> On Mon, Jul 04, 2005 at 11:16:21PM +0100, Nicholas Clark wrote:
> > This breaks t/spamd_hup.t in Mail-Spamassassin.
> 
> I've reduced it to the following. Looks like some sort of problem
> localizing hash slices. Will look into it further tomorrow sometime.

hash slice was a red-herring - it was a general problem unlocalizing
tainted values. Change 24943 basiucally threw out the baby with the
bathwater.

Fixed by the change below.

-- 
I've often wanted to drown my troubles, but I can't get my wife to go
swimming.


Change 25081 by [EMAIL PROTECTED] on 2005/07/05 13:01:23

        change 24943 broke restoration of localized taint values

Affected files ...

... //depot/perl/mg.c#357 edit
... //depot/perl/t/op/taint.t#67 edit

Differences ...

==== //depot/perl/mg.c#357 (text) ====

@@ -1921,10 +1921,13 @@
 Perl_magic_settaint(pTHX_ SV *sv, MAGIC *mg)
 {
     PERL_UNUSED_ARG(sv);
-    if (PL_tainted)
-       mg->mg_len |= 1;
-    else
-       mg->mg_len &= ~1;
+    /* update taint status unless we're restoring at scope exit */
+    if (PL_localizing != 2) {
+       if (PL_tainted)
+           mg->mg_len |= 1;
+       else
+           mg->mg_len &= ~1;
+    }
     return 0;
 }
 

==== //depot/perl/t/op/taint.t#67 (xtext) ====

@@ -17,7 +17,7 @@
 use File::Spec::Functions;
 
 BEGIN { require './test.pl'; }
-plan tests => 238;
+plan tests => 243;
 
 
 $| = 1;
@@ -1106,3 +1106,25 @@
         test not any_tainted @bar;
     }
 }
+
+# at scope exit, a restored localised value should have its old
+# taint status, not the taint status of the current statement
+
+{
+    our $x99 = $^X;
+    test tainted $x99;
+
+    $x99 = '';
+    test not tainted $x99;
+
+    my $c = do { local $x99; $^X };
+    test not tainted $x99;
+}
+{
+    our $x99 = $^X;
+    test tainted $x99;
+
+    my $c = do { local $x99; '' };
+    test tainted $x99;
+}
+

Reply via email to