6 require Config; import Config;
7 if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
13 use Test::More tests => 7;
14 use Scalar::Util qw/tainted/;
17 use POSIX qw(fcntl_h open read mkfifo);
27 # The empty tainted value, for tainting strings
29 my $TAINT = substr($^X, 0, 0);
31 # there is a bug in GUSI that causes problems trying to open
32 # files and directories ... it is being fixed, this is just
34 my $file = $^O eq 'MacOS' ? 'TEST-OLD' : 'TEST';
36 eval { mkfifo($TAINT. $file, 0) };
37 like($@, qr/^Insecure dependency/, 'mkfifo with tainted data');
39 eval { $testfd = open($TAINT. $file, O_WRONLY, 0) };
40 like($@, qr/^Insecure dependency/, 'open with tainted data');
42 eval { $testfd = open($file, O_RDONLY, 0) };
43 is($@, "", 'open with untainted data');
45 read($testfd, $buffer, 2) if $testfd > 2;
46 is( $buffer, "#!", ' read' );
47 ok(tainted($buffer), ' scalar tainted');
50 local $TODO = "POSIX::read won't taint an array element";
52 read($testfd, $buffer[1], 2) if $testfd > 2;
54 is( $buffer[1], "./", ' read' );
55 ok(tainted($buffer[1]), ' array element tainted');