my $TEST = catfile(curdir(), 'TEST');
-print "1..206\n";
+print "1..208\n";
# First, let's make sure that Perl is checking the dangerous
# environment variables. Maybe they aren't set yet, so we'll
$TAINT =~ /(.*)/;
test 206, tainted(my $foo = $1);
}
+
+{
+ # test with a non-magical %ENV (and non-magical %ENV elements)
+ our %nonmagicalenv = ( PATH => $TAINT );
+ local *ENV = \%nonmagicalenv;
+ eval { system("lskdfj"); };
+ test 207, $@ =~ /Insecure \$ENV{PATH} while running with -T switch/;
+ # [perl #24291] this used to dump core
+ %nonmagicalenv = ( PATH => "util" );
+ eval { system("lskdfj"); };
+ test 208, 1;
+}
NULL
};
- if (!PL_envgv)
+ /* Don't bother if there's no %ENV hash */
+ if (!PL_envgv || !GvHV(PL_envgv))
return;
#ifdef VMS
TAINT;
taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
}
- if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+ if (SvMAGICAL(*svp)
+ && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+ && MgTAINTEDDIR(mg)) {
TAINT;
taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
}
TAINT;
taint_proper("Insecure %s%s", "$ENV{PATH}");
}
- if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+ if (SvMAGICAL(*svp)
+ && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+ && MgTAINTEDDIR(mg)) {
TAINT;
taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
}