Skip to content

Commit 6c2afac

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 2371a9b commit 6c2afac

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,22 @@ EOPERL
15891589
'thread cloning during signature parse does not crash');
15901590
}
15911591

1592+
{
1593+
# https://github.com/Perl/perl5/pull/23871#discussion_r2488103875
1594+
$ENV{BAD} = "x";
1595+
fresh_perl_is(<<'CODE', "ok\n",
1596+
no warnings "experimental::signature_named_parameters";
1597+
use feature "signatures";
1598+
sub foo (:$x, @y) {
1599+
print "ok\n";
1600+
}
1601+
foo("$ENV{BAD}");
1602+
CODE
1603+
{
1604+
switches => [ "-t" ],
1605+
}, "crash in named parameter handling");
1606+
}
1607+
15921608
done_testing;
15931609

15941610
1;

0 commit comments

Comments
 (0)