Skip to content

Commit 9f28c63

Browse files
jbergerFather Chrysostomos
authored and
Father Chrysostomos
committed
Cwd::fast_abs_path's untaint should allow for multiline directories
This bug was noticed via Perl-Toolchain-Gang/File-chdir#3 and testing has led to this being the cause. The problem is worse on some platforms (notably cygwin in this case) when abs_path is implemented by fast_abs_path. Since File::chdir tests for proper behavior when a directory contains a newline, this bug then breaks File::chdir (one of my favorites and very useful xplatform tool). Yes this should have tests, but since it will involve creating a directory with a newline, I thought I would do better to leave that to someone with better knowledge than I.
1 parent 52ee8d0 commit 9f28c63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dist/Cwd/Cwd.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ sub fast_abs_path {
624624

625625
# Detaint else we'll explode in taint mode. This is safe because
626626
# we're not doing anything dangerous with it.
627-
($path) = $path =~ /(.*)/;
628-
($cwd) = $cwd =~ /(.*)/;
627+
($path) = $path =~ /(.*)/s;
628+
($cwd) = $cwd =~ /(.*)/s;
629629

630630
unless (-e $path) {
631631
_croak("$path: No such file or directory");

0 commit comments

Comments
 (0)