1#!perl -wT 2use strict; 3 4use Test::More tests => 7; 5 6use FindBin qw($Bin); 7use File::Spec; 8use Scalar::Util qw(tainted); 9 10use PerlIO::Util; 11 12# $^X is tainted 13my $tainted = substr($^X, 0, 0); 14 15my $path = File::Spec->join($Bin, 'util', 'taint') . $tainted; 16 17ok tainted($path), 'using tainted string'; 18 19eval{ 20 open my $tee, '>:tee', File::Spec->devnull, $path; 21}; 22like $@, qr/insecure/i, 'insecure :tee'; 23 24my $io; 25eval{ 26 $io = PerlIO::Util->open('>:tee', File::Spec->devnull); 27 $io->push_layer(tee => $path); 28}; 29like $@, qr/insecure/i, 'insecure :tee'; 30 31ok close($io), 'close io with a uninitialized layer'; 32 33eval{ 34 open my $io, '+<:creat', $path; 35}; 36like $@, qr/insecure/i, 'insecure :creat'; 37 38eval{ 39 open my $io, '+<:excl', $path; 40}; 41like $@, qr/insecure/i, 'insecure :excl'; 42 43END{ 44 ok !-e $path, 'file not created'; 45} 46