Hi Mark, LGTM.
Aaron On Sat, Nov 7, 2026 at 6:31 PM Mark Wielaard <[email protected]> wrote: > > An Elf descriptor has a "zero" class until the Ehdr is created. > gelf_fsize needs a valid class for the size table lookup. > > * libelf/gelf_fsize.c (gelf_fsize): Return zero and set libelf > errno to ELF_E_WRONG_ORDER_EHDR, when class is 0. > > Signed-off-by: Mark Wielaard <[email protected]> > --- > libelf/gelf_fsize.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/libelf/gelf_fsize.c b/libelf/gelf_fsize.c > index 6f99d83979aa..371f08f2cc2c 100644 > --- a/libelf/gelf_fsize.c > +++ b/libelf/gelf_fsize.c > @@ -100,6 +100,13 @@ gelf_fsize (Elf *elf, Elf_Type type, size_t count, > unsigned int version) > return 0; > } > > + /* Class is set from the Ehdr. */ > + if (elf->class == 0) > + { > + __libelf_seterrno (ELF_E_WRONG_ORDER_EHDR); > + return 0; > + } > + > return count * __libelf_type_sizes[elf->class - 1][type]; > } > INTDEF(gelf_fsize) > -- > 2.56.0 >
