Commit | Line | Data |
b454f38b |
1 | #!./perl -T |
2 | |
3 | BEGIN { |
4 | unless(grep /blib/, @INC) { |
5 | chdir 't' if -d 't'; |
20822f61 |
6 | @INC = '../lib'; |
b454f38b |
7 | } |
8 | } |
9 | |
10 | use Config; |
11 | |
12 | BEGIN { |
90b9a713 |
13 | if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') { |
14 | print "1..0\n"; |
15 | exit 0; |
b454f38b |
16 | } |
17 | } |
18 | |
19 | END { unlink "./__taint__$$" } |
20 | |
6e592b3a |
21 | print "1..5\n"; |
b454f38b |
22 | use IO::File; |
23 | $x = new IO::File "> ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
24 | print $x "$$\n"; |
25 | $x->close; |
26 | |
27 | $x = new IO::File "< ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
28 | chop($unsafe = <$x>); |
29 | eval { kill 0 * $unsafe }; |
2986a63f |
30 | print "not " if ((($^O ne 'MSWin32') && ($^O ne 'NetWare')) and ($@ !~ /^Insecure/o)); |
b454f38b |
31 | print "ok 1\n"; |
32 | $x->close; |
33 | |
34 | # We could have just done a seek on $x, but technically we haven't tested |
35 | # seek yet... |
36 | $x = new IO::File "< ./__taint__$$" || die("Cannot open ./__taint__$$\n"); |
37 | $x->untaint; |
38 | print "not " if ($?); |
39 | print "ok 2\n"; # Calling the method worked |
40 | chop($unsafe = <$x>); |
41 | eval { kill 0 * $unsafe }; |
42 | print "not " if ($@ =~ /^Insecure/o); |
43 | print "ok 3\n"; # No Insecure message from using the data |
44 | $x->close; |
45 | |
6e592b3a |
46 | # this will segfault if it fails |
47 | |
48 | sub PVBM () { 'foo' } |
49 | { my $dummy = index 'foo', PVBM } |
50 | |
51 | eval { IO::Handle::untaint(PVBM) }; |
52 | print "ok 4\n"; |
53 | |
54 | eval { IO::Handle::untaint(\PVBM) }; |
55 | print "ok 5\n"; |
56 | |
b454f38b |
57 | exit 0; |