develooper Front page | perl.perl5.changes | Postings from December 2008

Change 34990: Integrate:

From:
Nicholas Clark
Date:
December 3, 2008 03:00
Subject:
Change 34990: Integrate:
Change 34990 by nicholas@nicholas-saigo on 2008/12/03 10:55:42

	Integrate:
	[ 34988]
	Integrate:
	[ 34987]
	Fix for tainting regression in a test of Text::Template spotted by
	Andreas' smoker.

Affected files ...

... //depot/maint-5.8/perl/scope.c#78 integrate
... //depot/maint-5.8/perl/t/op/taint.t#28 integrate

Differences ...

==== //depot/maint-5.8/perl/scope.c#78 (text) ====
Index: perl/scope.c
--- perl/scope.c#77~34978~	2008-12-02 06:23:08.000000000 -0800
+++ perl/scope.c	2008-12-03 02:55:42.000000000 -0800
@@ -614,6 +614,8 @@
     void* ptr;
     register char* str;
     I32 i;
+    /* Localise the effects of the TAINT_NOT inside the loop.  */
+    const bool was = PL_tainted;
 
     if (base < -1)
 	Perl_croak(aTHX_ "panic: corrupt saved stack index");
@@ -1064,6 +1066,8 @@
 	    Perl_croak(aTHX_ "panic: leave_scope inconsistency");
 	}
     }
+
+    PL_tainted = was;
 }
 
 void

==== //depot/maint-5.8/perl/t/op/taint.t#28 (xtext) ====
Index: perl/t/op/taint.t
--- perl/t/op/taint.t#27~34299~	2008-09-06 08:27:08.000000000 -0700
+++ perl/t/op/taint.t	2008-12-03 02:55:42.000000000 -0800
@@ -17,7 +17,7 @@
 use File::Spec::Functions;
 
 BEGIN { require './test.pl'; }
-plan tests => 263;
+plan tests => 290;
 
 $| = 1;
 
@@ -1241,6 +1241,42 @@
     ok(!tainted($1), "\\S match with chr $ord");
 }
 
+{
+    my @data = qw(bonk zam zlonk qunckkk);
+    # Clearly some sort of usenet bang-path
+    my $string = $TAINT . join "!", @data;
+
+    ok(tainted($string), "tainted data");
+
+    my @got = split /!|,/, $string;
+
+    # each @got would be useful here, but I want the test for earlier perls
+    for my $i (0 .. $#data) {
+	ok(tainted($got[$i]), "tainted result $i");
+	is($got[$i], $data[$i], "correct content $i");
+    }
+
+    ok(tainted($string), "still tainted data");
+
+    my @got = split /[!,]/, $string;
+
+    # each @got would be useful here, but I want the test for earlier perls
+    for my $i (0 .. $#data) {
+	ok(tainted($got[$i]), "tainted result $i");
+	is($got[$i], $data[$i], "correct content $i");
+    }
+
+    ok(tainted($string), "still tainted data");
+
+    my @got = split /!/, $string;
+
+    # each @got would be useful here, but I want the test for earlier perls
+    for my $i (0 .. $#data) {
+	ok(tainted($got[$i]), "tainted result $i");
+	is($got[$i], $data[$i], "correct content $i");
+    }
+}
+
 # This may bomb out with the alarm signal so keep it last
 SKIP: {
     skip "No alarm()"  unless $Config{d_alarm};
End of Patch.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About