by Schwern.
p4raw-id: //depot/perl@11873
ext/ByteLoader/byterun.h Header for byterun.c
ext/ByteLoader/hints/sunos.pl Hints for named architecture
ext/ByteLoader/Makefile.PL Bytecode loader makefile writer
-ext/Cwd/Cwd.t See if Cwd works
-ext/Cwd/Cwd.xs Cwd extension external subroutines
-ext/Cwd/Makefile.PL Cwd extension makefile maker
+ext/Cwd/Cwd.xs Cwd extension external subroutines
+ext/Cwd/t/cwd.t See if Cwd works
+ext/Cwd/t/taint.t See if Cwd works with taint
+ext/Cwd/Makefile.PL Cwd extension makefile maker
ext/Data/Dumper/Changes Data pretty printer, changelog
ext/Data/Dumper/Dumper.pm Data pretty printer, module
ext/Data/Dumper/Dumper.xs Data pretty printer, externals
{
dXSTARG;
char *path;
- STRLEN len;
char buf[MAXPATHLEN];
- if (pathsv)
- path = SvPV(pathsv, len);
- else {
- path = ".";
- len = 1;
- }
+ path = pathsv ? SvPV_nolen(pathsv) : ".";
if (bsd_realpath(path, buf)) {
sv_setpvn(TARG, buf, strlen(buf));
SvPOK_only(TARG);
+ SvTAINTED_on(TARG);
}
else
- sv_setsv(TARG, &PL_sv_undef);
+ sv_setsv(TARG, &PL_sv_undef);
XSprePUSH; PUSHTARG;
+#ifndef INCOMPLETE_TAINTS
+ SvTAINTED_on(TARG);
+#endif
}
--- /dev/null
+#!./perl -Tw
+# Testing Cwd under taint mode.
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+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 };
+}
+
+my $cwd;
+eval { $cwd = getcwd; };
+is( $@, '', 'getcwd() does not explode under taint mode' );
+ok( is_tainted($cwd), "it's return value is tainted" );
+
{
#ifndef PERL_MICRO
+#ifndef INCOMPLETE_TAINTS
+ SvTAINTED_on(sv);
+#endif
+
#ifdef HAS_GETCWD
{
char buf[MAXPATHLEN];