with DEBUG_LEAKING_SCALARS, dump multiply-freed scalars
[p5sagit/p5-mst-13.2.git] / ext / IO / t / io_taint.t
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 ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
14         print "1..0\n";
15         exit 0;
16     }
17 }
18
19 END { unlink "./__taint__$$" }
20
21 print "1..3\n";
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 };
30 print "not " if ((($^O ne 'MSWin32') && ($^O ne 'NetWare')) and ($@ !~ /^Insecure/o));
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
46 exit 0;