summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-11-07 14:23:08 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-11-07 14:23:08 +0000
commit20ee07fbbcfa6be9f90bb8e5474a4d69d7396617 (patch)
tree87e5cf2fe703defa8b16f8bfff236db0bdad5d2d /t
parentd6686524f4a322ce27e0eebf255af3fb3431796c (diff)
downloadperl-20ee07fbbcfa6be9f90bb8e5474a4d69d7396617.tar.gz
Forbid using tainted formats in printf and sprintf
p4raw-id: //depot/perl@29225
Diffstat (limited to 't')
-rwxr-xr-xt/op/taint.t13
1 files changed, 12 insertions, 1 deletions
diff --git a/t/op/taint.t b/t/op/taint.t
index 8311690194..be9071fdd2 100755
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ use Config;
use File::Spec::Functions;
BEGIN { require './test.pl'; }
-plan tests => 251;
+plan tests => 255;
$| = 1;
@@ -1204,3 +1204,14 @@ SKIP:
$o->untainted;
}
+{
+ # tests for tainted format in s?printf
+ eval { printf($TAINT . "# %s\n", "foo") };
+ like($@, qr/^Insecure dependency in printf/, q/printf doesn't like tainted formats/);
+ eval { printf("# %s\n", $TAINT . "foo") };
+ ok(!$@, q/printf accepts other tainted args/);
+ eval { sprintf($TAINT . "# %s\n", "foo") };
+ like($@, qr/^Insecure dependency in sprintf/, q/sprintf doesn't like tainted formats/);
+ eval { sprintf("# %s\n", $TAINT . "foo") };
+ ok(!$@, q/sprintf accepts other tainted args/);
+}