summaryrefslogtreecommitdiff
path: root/t/op/taint.t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-03-14 16:04:59 +0000
committerDavid Mitchell <davem@iabyn.com>2011-03-14 16:31:25 +0000
commite06d98fb28fb93799939b64c5cd2d41f83060c81 (patch)
tree933c857945a62c61ecdfb5461eb9c1b10c8fe79a /t/op/taint.t
parent295c2f7d5349d9417307a84d22b5ba63d9a655ed (diff)
downloadperl-e06d98fb28fb93799939b64c5cd2d41f83060c81.tar.gz
[perl #82250] fix tainted (s)print format
commit 20ee07fbbcfa6be9f90bb8e5474a4d69d7396617 introduced dieing in (s)printf when the format is tainted; however it only worked when the format is part of an expression (because TAINT_PROPER checks for PL_tainted being set). Fix by doing TAINT_PROPER only after get magic has been done on the format SV (which will set PL_tainted). This is done by moving the checks in pp_sprintf and pp_prtf into do_sprintf() (which is called by the two pp functions).
Diffstat (limited to 't/op/taint.t')
-rw-r--r--t/op/taint.t11
1 files changed, 8 insertions, 3 deletions
diff --git a/t/op/taint.t b/t/op/taint.t
index ae031cf7bb..c695570bfe 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
use strict;
use Config;
-plan tests => 766;
+plan tests => 770;
$| = 1;
@@ -1829,12 +1829,17 @@ SKIP:
{
# tests for tainted format in s?printf
- violates_taint(sub { printf($TAINT . "# %s\n", "foo") }, 'printf',
+ my $fmt = $TAINT . "# %s\n";
+ violates_taint(sub { printf($fmt, "foo") }, 'printf',
q/printf doesn't like tainted formats/);
+ violates_taint(sub { printf($TAINT . "# %s\n", "foo") }, 'printf',
+ q/printf doesn't like tainted format expressions/);
eval { printf("# %s\n", $TAINT . "foo") };
is($@, '', q/printf accepts other tainted args/);
- violates_taint(sub { sprintf($TAINT . "# %s\n", "foo") }, 'sprintf',
+ violates_taint(sub { sprintf($fmt, "foo") }, 'sprintf',
q/sprintf doesn't like tainted formats/);
+ violates_taint(sub { sprintf($TAINT . "# %s\n", "foo") }, 'sprintf',
+ q/sprintf doesn't like tainted format expressions/);
eval { sprintf("# %s\n", $TAINT . "foo") };
is($@, '', q/sprintf accepts other tainted args/);
}