From: Rafael Garcia-Suarez Date: Tue, 6 Nov 2001 21:45:01 +0000 (+0100) Subject: a bunch of untested patches X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a384e9e1be3de1dac7ce4a6952ba555727054ca7;p=p5sagit%2Fp5-mst-13.2.git a bunch of untested patches Message-ID: <20011106214501.A704@rafael> p4raw-id: //depot/perl@12879 --- diff --git a/lib/File/Spec/OS2.pm b/lib/File/Spec/OS2.pm index 20bf8c9..6392ba4 100644 --- a/lib/File/Spec/OS2.pm +++ b/lib/File/Spec/OS2.pm @@ -33,7 +33,15 @@ my $tmpdir; sub tmpdir { return $tmpdir if defined $tmpdir; my $self = shift; - foreach (@ENV{qw(TMPDIR TEMP TMP)}, qw(/tmp /)) { + my @dirlist = ( @ENV{qw(TMPDIR TEMP TMP)}, qw(/tmp /) ); + { + no strict 'refs'; + if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 + require Scalar::Util; + @dirlist = grep { ! Scalar::Util::tainted $_ } @dirlist; + } + } + foreach (@dirlist) { next unless defined && -d; $tmpdir = $_; last; diff --git a/lib/File/Spec/VMS.pm b/lib/File/Spec/VMS.pm index 184c827..325af08 100644 --- a/lib/File/Spec/VMS.pm +++ b/lib/File/Spec/VMS.pm @@ -269,12 +269,23 @@ from the following list or '' if none are writable: sys$scratch: $ENV{TMPDIR} +Since perl 5.8.0, if running under taint mode, and if $ENV{TMPDIR} +is tainted, it is not used. + =cut my $tmpdir; sub tmpdir { return $tmpdir if defined $tmpdir; - foreach ('sys$scratch:', $ENV{TMPDIR}) { + my @dirlist = ('sys$scratch:', $ENV{TMPDIR}); + { + no strict 'refs'; + if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 + require Scalar::Util; + pop @dirlist if Scalar::Util::tainted($ENV{TMPDIR}); + } + } + foreach (@dirlist) { next unless defined && -d && -w _; $tmpdir = $_; last; diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm index 519fb86..d2e94bc 100644 --- a/lib/File/Spec/Win32.pm +++ b/lib/File/Spec/Win32.pm @@ -47,13 +47,24 @@ from the following list: /tmp / +Since perl 5.8.0, if running under taint mode, and if the environment +variables are tainted, they are not used. + =cut my $tmpdir; sub tmpdir { return $tmpdir if defined $tmpdir; my $self = shift; - foreach (@ENV{qw(TMPDIR TEMP TMP)}, qw(C:/temp /tmp /)) { + my @dirlist = (@ENV{qw(TMPDIR TEMP TMP)}, qw(C:/temp /tmp /)); + { + no strict 'refs'; + if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 + require Scalar::Util; + @dirlist = grep { ! Scalar::Util::tainted $_ } @dirlist; + } + } + foreach (@dirlist) { next unless defined && -d; $tmpdir = $_; last;