| 1 | #!./perl -T |
| 2 | |
| 3 | BEGIN { |
| 4 | unless(grep /blib/, @INC) { |
| 5 | chdir 't' if -d 't'; |
| 6 | @INC = '../lib'; |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | use Config; |
| 11 | |
| 12 | BEGIN { |
| 13 | if(-d "lib" && -f "TEST") { |
| 14 | if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') { |
| 15 | print "1..0\n"; |
| 16 | exit 0; |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | END { unlink "./__taint__$$" } |
| 22 | |
| 23 | print "1..3\n"; |
| 24 | use IO::File; |
| 25 | $x = new IO::File "> ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
| 26 | print $x "$$\n"; |
| 27 | $x->close; |
| 28 | |
| 29 | $x = new IO::File "< ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
| 30 | chop($unsafe = <$x>); |
| 31 | eval { kill 0 * $unsafe }; |
| 32 | print "not " if $^O ne 'MSWin32' and ($@ !~ /^Insecure/o); |
| 33 | print "ok 1\n"; |
| 34 | $x->close; |
| 35 | |
| 36 | # We could have just done a seek on $x, but technically we haven't tested |
| 37 | # seek yet... |
| 38 | $x = new IO::File "< ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
| 39 | $x->untaint; |
| 40 | print "not " if ($?); |
| 41 | print "ok 2\n"; # Calling the method worked |
| 42 | chop($unsafe = <$x>); |
| 43 | eval { kill 0 * $unsafe }; |
| 44 | print "not " if ($@ =~ /^Insecure/o); |
| 45 | print "ok 3\n"; # No Insecure message from using the data |
| 46 | $x->close; |
| 47 | |
| 48 | exit 0; |