Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit d7abc28

Browse files
committed
Disallow pad_findmy_pvn flags, no UTF8
With cperl all pads are stored as utf8. Fix one forgotten call in ck_sort, caught by afl-fuzzing id:000113,sig:06,src:029639+026337,op:splice,rep:4 id:000142,sig:11,src:027004,op:havoc,rep:32 in #293
1 parent 27c9cdd commit d7abc28

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12974,7 +12974,7 @@ Perl_ck_sort(pTHX_ OP *o)
1297412974
*tmpbuf = '&';
1297512975
assert (len < TOKENBUF_SIZE);
1297612976
Copy(name, tmpbuf+1, len, char);
12977-
off = pad_findmy_pvn(tmpbuf, len+1, SvUTF8(kSVOP_sv));
12977+
off = pad_findmy_pvn(tmpbuf, len+1, 0); /* all pads are UTF8 */
1297812978
if (off != NOT_IN_PAD) {
1297912979
if (PAD_COMPNAME_FLAGS_isOUR(off)) {
1298012980
SV * const fq =

pad.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash)
945945
Given the name of a lexical variable, find its position in the
946946
currently-compiling pad.
947947
C<namepv>/C<namelen> specify the variable's name, including leading sigil.
948-
C<flags> is reserved and must be zero.
948+
C<flags> is reserved and must be zero. (Pads are all UTF8 in cperl)
949949
If it is not in the current pad but appears in the pad of any lexically
950950
enclosing scope, then a pseudo-entry for it is added in the current pad.
951951
Returns the offset in the current pad,
@@ -966,16 +966,16 @@ Perl_pad_findmy_pvn(pTHX_ const char *namepv, STRLEN namelen, U32 flags)
966966
PERL_ARGS_ASSERT_PAD_FINDMY_PVN;
967967

968968
pad_peg("pad_findmy_pvn");
969-
970969
if (flags)
970+
/* With cperl all PADs are UTF8 */
971971
Perl_croak(aTHX_ "panic: pad_findmy_pvn illegal flag bits 0x%" UVxf,
972972
(UV)flags);
973973

974974
/* compilation errors can zero PL_compcv */
975975
if (!PL_compcv)
976976
return NOT_IN_PAD;
977977

978-
offset = pad_findlex(namepv, namelen, flags,
978+
offset = pad_findlex(namepv, namelen, 0,
979979
PL_compcv, PL_cop_seqmax, 1, NULL, &out_pn, &out_flags);
980980
if (offset != NOT_IN_PAD)
981981
return offset;
@@ -1010,13 +1010,15 @@ Perl_pad_findmy_pvn(pTHX_ const char *namepv, STRLEN namelen, U32 flags)
10101010
Exactly like L</pad_findmy_pvn>, but takes a nul-terminated string
10111011
instead of a string/length pair.
10121012
1013+
flags must be 0.
10131014
=cut
10141015
*/
10151016

10161017
PADOFFSET
10171018
Perl_pad_findmy_pv(pTHX_ const char *name, U32 flags)
10181019
{
10191020
PERL_ARGS_ASSERT_PAD_FINDMY_PV;
1021+
assert(!flags);
10201022
return pad_findmy_pvn(name, strlen(name), flags);
10211023
}
10221024

@@ -1026,6 +1028,7 @@ Perl_pad_findmy_pv(pTHX_ const char *name, U32 flags)
10261028
Exactly like L</pad_findmy_pvn>, but takes the name string in the form
10271029
of an SV instead of a string/length pair.
10281030
1031+
flags must be 0, all pads are utf8
10291032
=cut
10301033
*/
10311034

@@ -1036,6 +1039,7 @@ Perl_pad_findmy_sv(pTHX_ SV *name, U32 flags)
10361039
STRLEN namelen;
10371040
PERL_ARGS_ASSERT_PAD_FINDMY_SV;
10381041
namepv = SvPVutf8(name, namelen);
1042+
assert(!flags);
10391043
return pad_findmy_pvn(namepv, namelen, flags);
10401044
}
10411045

@@ -1125,6 +1129,8 @@ as it goes. It has to be this way
11251129
because fake names in anon protoypes have to store in C<xpadn_low> the
11261130
index into the parent pad.
11271131
1132+
PADs are with cperl all UTF8 so the flags argument must be 0 or padadd_STALEOK.
1133+
11281134
=cut
11291135
*/
11301136

@@ -1159,8 +1165,9 @@ S_pad_findlex(pTHX_ const char *namepv, STRLEN namelen, U32 flags, const CV* cv,
11591165

11601166
PERL_ARGS_ASSERT_PAD_FINDLEX;
11611167

1162-
flags &= ~ padadd_STALEOK; /* one-shot flag */
1168+
flags &= ~padadd_STALEOK; /* one-shot flag */
11631169
if (flags)
1170+
/* With cperl all PADs are utf8 */
11641171
Perl_croak(aTHX_ "panic: pad_findlex illegal flag bits 0x%" UVxf,
11651172
(UV)flags);
11661173

0 commit comments

Comments
 (0)