In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/3b36395d31cf0a2f3a017505cd0ea857a7acb5d1?hp=60b7c710a2f8d8a0284e51aeee6648d17989f952>

- Log -----------------------------------------------------------------
commit 3b36395d31cf0a2f3a017505cd0ea857a7acb5d1
Author: David Mitchell <[email protected]>
Date:   Tue Jun 28 17:04:40 2011 +0100

    RT 64804: tainting with index() of a constant
    
    At compile time, ck_index with a tainted constant set PL_tainted,
    which remained on during the rest of compilation, tainting all other
    constants.
    
    Fix this by saving and restoring PL_tainted across the call to
    fbm_compile, which is what sets PL_tainted.

M       op.c
M       t/op/taint.t

commit 0d1104b41d261582aa0acf80a85ad039e46c89d7
Author: Niko Tyni <[email protected]>
Date:   Fri Apr 17 21:11:08 2009 +0300

    TODO test for index() of a tainted constant
    
    As reported by Adrian Irving-Beer in <http://bugs.debian.org/291450>,
    this unexpectedly throws a fatal taint error:
    
        #!/usr/bin/perl -T
        use constant C_A => $ARGV[0];
        use constant C_B => $ARGV[1];
        index(C_A, C_B);
        open(FOO, "-|");
    
    The TODO test is reduced from the above.

M       t/op/taint.t
-----------------------------------------------------------------------

Summary of changes:
 op.c         |    5 ++++-
 t/op/taint.t |   16 +++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/op.c b/op.c
index 6b4bf6b..eab717a 100644
--- a/op.c
+++ b/op.c
@@ -7786,8 +7786,11 @@ Perl_ck_index(pTHX_ OP *o)
        OP *kid = cLISTOPo->op_first->op_sibling;       /* get past pushmark */
        if (kid)
            kid = kid->op_sibling;                      /* get past "big" */
-       if (kid && kid->op_type == OP_CONST)
+       if (kid && kid->op_type == OP_CONST) {
+           const bool save_taint = PL_tainted;
            fbm_compile(((SVOP*)kid)->op_sv, 0);
+           PL_tainted = save_taint;
+       }
     }
     return ck_fun(o);
 }
diff --git a/t/op/taint.t b/t/op/taint.t
index 0c9c2d0..02eac80 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
 use strict;
 use Config;
 
-plan tests => 780;
+plan tests => 784;
 
 $| = 1;
 
@@ -2168,6 +2168,20 @@ end
     }
 }
 
+
+# tainted constants and index()
+#  RT 64804; http://bugs.debian.org/291450
+{
+    ok(tainted $old_env_path, "initial taintedness");
+    BEGIN { no strict 'refs'; my $v = $old_env_path; *{"::C"} = sub () { $v }; 
}
+    ok(tainted C, "constant is tainted properly");
+    ok(!tainted "", "tainting not broken yet");
+    index(undef, C);
+    ok(!tainted "", "tainting still works after index() of the constant");
+}
+
+
+
 # This may bomb out with the alarm signal so keep it last
 SKIP: {
     skip "No alarm()"  unless $Config{d_alarm};

--
Perl5 Master Repository

Reply via email to