Change 17678 by [EMAIL PROTECTED] on 2002/08/04 15:34:19

        Subject: Re: [ID 20020704.001] my $foo = $1 won't taint $foo (with use re 
'taint')
        From: [EMAIL PROTECTED]
        Date: Sun, 04 Aug 2002 17:40:30 +0100
        Message-id: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/mg.c#236 edit
.... //depot/perl/t/op/taint.t#52 edit

Differences ...

==== //depot/perl/mg.c#236 (text) ====
Index: perl/mg.c
--- perl/mg.c#235~16845~        Tue May 28 15:05:55 2002
+++ perl/mg.c   Sun Aug  4 08:34:19 2002
@@ -693,18 +693,24 @@
 
              getrx:
                if (i >= 0) {
-                   bool was_tainted = FALSE;
-                   if (PL_tainting) {
-                       was_tainted = PL_tainted;
-                       PL_tainted = FALSE;
-                   }
                    sv_setpvn(sv, s, i);
-                   if (PL_reg_match_utf8 && is_utf8_string((U8*)s, i))
+                   if (PL_reg_match_utf8 && is_utf8_string((U8*)s, i))
                        SvUTF8_on(sv);
                    else
                        SvUTF8_off(sv);
                    if (PL_tainting)
-                       PL_tainted = (was_tainted || RX_MATCH_TAINTED(rx));
+                       PL_tainted = PL_tainted || !!RX_MATCH_TAINTED(rx);
+                   if (RX_MATCH_TAINTED(rx)) {
+                       MAGIC* mg = SvMAGIC(sv);
+                       MAGIC* mgt;
+                       SvMAGIC(sv) = mg->mg_moremagic;
+                       SvTAINT(sv);
+                       if ((mgt = SvMAGIC(sv))) {
+                           mg->mg_moremagic = mgt;
+                           SvMAGIC(sv) = mg;
+                       }
+                   } else
+                       SvTAINTED_off(sv);
                    break;
                }
            }

==== //depot/perl/t/op/taint.t#52 (xtext) ====
Index: perl/t/op/taint.t
--- perl/t/op/taint.t#51~17677~ Sun Aug  4 08:25:25 2002
+++ perl/t/op/taint.t   Sun Aug  4 08:34:19 2002
@@ -124,7 +124,7 @@
 
 my $TEST = catfile(curdir(), 'TEST');
 
-print "1..205\n";
+print "1..206\n";
 
 # First, let's make sure that Perl is checking the dangerous
 # environment variables. Maybe they aren't set yet, so we'll
@@ -970,4 +970,11 @@
     test 205, $@ eq '';
 
     # If you add tests here update also the above skip block for VMS.
+}
+
+{
+    # [ID 20020704.001] taint propagation failure
+    use re 'taint';
+    $TAINT =~ /(.*)/;
+    test 206, tainted(my $foo = $1);
 }
End of Patch.

Reply via email to