4 require Config; import Config;
5 if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
11 use Test::More tests => 7;
12 use Scalar::Util qw/tainted/;
15 use POSIX qw(fcntl_h open read mkfifo);
25 # The empty tainted value, for tainting strings
27 my $TAINT = substr($^X, 0, 0);
29 my $file = 'POSIX.xs';
31 eval { mkfifo($TAINT. $file, 0) };
32 like($@, qr/^Insecure dependency/, 'mkfifo with tainted data');
34 eval { $testfd = open($TAINT. $file, O_WRONLY, 0) };
35 like($@, qr/^Insecure dependency/, 'open with tainted data');
37 eval { $testfd = open($file, O_RDONLY, 0) };
38 is($@, "", 'open with untainted data');
40 read($testfd, $buffer, 2) if $testfd > 2;
41 is( $buffer, "#d", ' read' );
42 ok(tainted($buffer), ' scalar tainted');
45 local $TODO = "POSIX::read won't taint an array element";
47 read($testfd, $buffer[1], 2) if $testfd > 2;
49 is( $buffer[1], "./", ' read' );
50 ok(tainted($buffer[1]), ' array element tainted');