diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-05-16 21:09:57 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-05-16 21:09:57 +0000 |
commit | 248785eb434790c6e30dbaca63ce310c33712c18 (patch) | |
tree | 78e86449aa5e9701176455e16170546dfbc44f67 /ext | |
parent | a2147dfeb7f10f2a9fc88c101af1f63b2ab8f9f9 (diff) | |
download | perl-248785eb434790c6e30dbaca63ce310c33712c18.tar.gz |
Make Cwd::fastcwd() return a tainted value.
Add regression tests for taint-safety of the *cwd()
functions.
p4raw-id: //depot/perl@16635
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Cwd/Cwd.xs | 3 | ||||
-rw-r--r-- | ext/Cwd/t/taint.t | 19 |
2 files changed, 14 insertions, 8 deletions
diff --git a/ext/Cwd/Cwd.xs b/ext/Cwd/Cwd.xs index f53f6ee19e..3f7b93b231 100644 --- a/ext/Cwd/Cwd.xs +++ b/ext/Cwd/Cwd.xs @@ -222,6 +222,9 @@ PPCODE: dXSTARG; getcwd_sv(TARG); XSprePUSH; PUSHTARG; +#ifndef INCOMPLETE_TAINTS + SvTAINTED_on(TARG); +#endif } void diff --git a/ext/Cwd/t/taint.t b/ext/Cwd/t/taint.t index 74e2d65d00..3f6aa5290d 100644 --- a/ext/Cwd/t/taint.t +++ b/ext/Cwd/t/taint.t @@ -7,15 +7,18 @@ BEGIN { } use Cwd; -use Test::More tests => 2; - -# The normal kill() trick is not portable. -sub is_tainted { - return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 }; -} +use Test::More tests => 6; +use Scalar::Util qw/tainted/; my $cwd; eval { $cwd = getcwd; }; -is( $@, '', 'getcwd() does not explode under taint mode' ); -ok( is_tainted($cwd), "its return value is tainted" ); +is( $@, '', 'getcwd() does not explode under taint mode' ); +ok( tainted($cwd), "its return value is tainted" ); + +eval { $cwd = cwd; }; +is( $@, '', 'cwd() does not explode under taint mode' ); +ok( tainted($cwd), "its return value is tainted" ); +eval { $cwd = fastcwd; }; +is( $@, '', 'fastcwd() does not explode under taint mode' ); +ok( tainted($cwd), "its return value is tainted" ); |