This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RT 64804: tainting with index() of a constant
authorDavid Mitchell <davem@iabyn.com>
Tue, 28 Jun 2011 16:04:40 +0000 (17:04 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 28 Jun 2011 16:04:40 +0000 (17:04 +0100)
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.

op.c
t/op/taint.t

diff --git a/op.c b/op.c
index 6b4bf6b..eab717a 100644 (file)
--- 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);
 }
index edbdf49..02eac80 100644 (file)
@@ -2177,7 +2177,6 @@ end
     ok(tainted C, "constant is tainted properly");
     ok(!tainted "", "tainting not broken yet");
     index(undef, C);
-    local $::TODO = 'breaks when fbm_compile() is called';
     ok(!tainted "", "tainting still works after index() of the constant");
 }