diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2001-11-05 18:10:29 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-05 15:16:24 +0000 |
commit | b4c5e263c3e0ec8af3615a4049145b94b9d139bd (patch) | |
tree | c168080d79356b151af4e10eefe69a7e536750b2 /lib/File | |
parent | 965a5e93b44f682e7eb38d20bcbc5430bf019de1 (diff) | |
download | perl-b4c5e263c3e0ec8af3615a4049145b94b9d139bd.tar.gz |
Re: Tainted $ENV{TMPDIR} and File::Spec->tmpdir()
Message-ID: <1004976629.3be6b9f593085@imp3-1.free.fr>
p4raw-id: //depot/perl@12854
Diffstat (limited to 'lib/File')
-rw-r--r-- | lib/File/Spec/Unix.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm index fcbe76765b..32ace3bff4 100644 --- a/lib/File/Spec/Unix.pm +++ b/lib/File/Spec/Unix.pm @@ -3,7 +3,7 @@ package File::Spec::Unix; use strict; our($VERSION); -$VERSION = '1.3'; +$VERSION = '1.4'; use Cwd; @@ -124,12 +124,20 @@ from the following list or "" if none are writable: $ENV{TMPDIR} /tmp +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 ($ENV{TMPDIR}, "/tmp") { + my @dirlist = ($ENV{TMPDIR}, "/tmp"); + if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 + require Scalar::Util; + shift @dirlist if Scalar::Util::tainted($ENV{TMPDIR}); + } + foreach (@dirlist) { next unless defined && -d && -w _; $tmpdir = $_; last; |