sv_setsv(sv, &PL_sv_undef);
break;
case '\017': /* ^O & ^OPEN */
- if (*(mg->mg_ptr+1) == '\0')
+ if (*(mg->mg_ptr+1) == '\0') {
sv_setpv(sv, PL_osname);
+ SvTAINTED_off(sv);
+ }
else if (strEQ(mg->mg_ptr, "\017PEN")) {
if (!PL_compiling.cop_io)
sv_setsv(sv, &PL_sv_undef);
if (*(mg->mg_ptr+1) == '\0') {
if (PL_osname)
Safefree(PL_osname);
- if (SvOK(sv))
+ if (SvOK(sv)) {
+ TAINT_PROPER("assigning to $^O");
PL_osname = savepv(SvPV(sv,len));
+ }
else
PL_osname = Nullch;
}
my $TEST = catfile(curdir(), 'TEST');
-print "1..220\n";
+print "1..223\n";
# First, let's make sure that Perl is checking the dangerous
# environment variables. Maybe they aren't set yet, so we'll
test 219, !tainted($1);
($r = $TAINT) =~ /($TAINT)/;
test 220, tainted($1);
+
+ # [perl #24674]
+ # accessing $^O shoudn't taint it as a side-effect;
+ # assigning tainted data to it is now an error
+
+ test 221, !tainted($^O);
+ if (!$^X) { } elsif ($^O eq 'bar') { }
+ test 222, !tainted($^O);
+ eval '$^O = $^X';
+ test 223, $@ =~ /Insecure dependency in/;
}