diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-09-04 13:39:13 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-05 12:12:18 +0000 |
commit | 3547aa9a8aaf2eba7e5ab912d32d7292dd5fcb51 (patch) | |
tree | edf4fa57ec48ecabc71861f9ab3aeb168853cba9 /lib/Cwd.pm | |
parent | d3632a54487acc5f59859996dcd6594d894cdc1a (diff) | |
download | perl-3547aa9a8aaf2eba7e5ab912d32d7292dd5fcb51.tar.gz |
cwd() taint safe (was Re: [PATCH lib/Cwd.pm ext/Cwd/Makefile.PL] Full doc cleanup (was Re: [PATCH lib/Cwd.pm] Try this again.))
Message-ID: <20010904173913.C626@blackrider>
p4raw-id: //depot/perl@11879
Diffstat (limited to 'lib/Cwd.pm')
-rw-r--r-- | lib/Cwd.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Cwd.pm b/lib/Cwd.pm index 3c5c50a35c..37217fa01e 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -131,10 +131,22 @@ eval { XSLoader::load('Cwd'); }; -# The 'natural and safe form' for UNIX (pwd may be setuid root) +# Find the pwd command in the expected locations. We assume these +# are safe. This prevents _backtick_pwd() consulting $ENV{PATH} +# so everything works under taint mode. +my $pwd_cmd; +foreach my $try (qw(/bin/pwd /usr/bin/pwd)) { + if( -x $try ) { + $pwd_cmd = $try; + last; + } +} +$pwd_cmd ||= 'pwd'; + +# The 'natural and safe form' for UNIX (pwd may be setuid root) sub _backtick_pwd { - my $cwd = `pwd`; + my $cwd = `$pwd_cmd`; # `pwd` may fail e.g. if the disk is full chomp($cwd) if defined $cwd; $cwd; |