From 3b36395d31cf0a2f3a017505cd0ea857a7acb5d1 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Tue, 28 Jun 2011 17:04:40 +0100 Subject: [PATCH] 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. --- op.c | 5 ++++- t/op/taint.t | 1 - 2 files changed, 4 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 edbdf49..02eac80 100644 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -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"); } -- 2.7.4