Skip to content

Commit d98b252

Browse files
committed
named signatures: fix crash when slurping and tainting
Only try to dereference a parameter pointer after we ensure it is valid. CID 638315
1 parent e3d32ae commit d98b252

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

pp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8021,13 +8021,13 @@ PP(pp_multiparam)
80218021
SV **padentry = &PAD_SVl(padix);
80228022
save_clearsv(padentry);
80238023

8024+
if(!val)
8025+
val = &PL_sv_undef;
8026+
80248027
assert(TAINTING_get || !TAINT_get);
80258028
if (UNLIKELY(TAINT_get) && !SvTAINTED(val))
80268029
TAINT_NOT;
80278030

8028-
if(!val)
8029-
val = &PL_sv_undef;
8030-
80318031
SvPADSTALE_off(*padentry);
80328032
SvSetMagicSV(*padentry, val);
80338033
}

t/op/signatures.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,25 @@ EOPERL
15891589
'thread cloning during signature parse does not crash');
15901590
}
15911591

1592+
SKIP:
1593+
{
1594+
skip "No taint support", 1
1595+
if exists $Config{taint_support} && !$Config{taint_support};
1596+
# https://github.com/Perl/perl5/pull/23871#discussion_r2488103875
1597+
$ENV{BAD} = "x";
1598+
fresh_perl_is(<<'CODE', "ok\n",
1599+
no warnings "experimental::signature_named_parameters";
1600+
use feature "signatures";
1601+
sub foo (:$x, @y) {
1602+
print "ok\n";
1603+
}
1604+
foo("$ENV{BAD}");
1605+
CODE
1606+
{
1607+
switches => [ "-t" ],
1608+
}, "crash in named parameter handling");
1609+
}
1610+
15921611
done_testing;
15931612

15941613
1;

0 commit comments

Comments
 (0)