From: Mark Wielaard Date: Wed, 27 Mar 2019 20:54:06 +0000 (+0100) Subject: strip: Files with symbols referring to non-existing sections are illformed X-Git-Tag: elfutils-0.177~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f03ac75239e0981deaf4aa18f66f423bcc5ce051;p=thirdparty%2Felfutils.git strip: Files with symbols referring to non-existing sections are illformed The check added in commit 4540ea98c "strip: Fix check test for SHN_XINDEX symbol" was not complete. The (extended) section index should also exist. If it doesn't exist, mark the file as illformed. https://sourceware.org/bugzilla/show_bug.cgi?id=24385 Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index 0544fceba..fb1ac0964 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2019-03-27 Mark Wielaard + + * strip (handle_elf): Assert that symbol section number exists. + 2019-01-24 Mark Wielaard * strip.c (handle_elf): Fix check test for SHN_XINDEX symbol. diff --git a/src/strip.c b/src/strip.c index a73009d98..4cd87506e 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1975,6 +1975,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, && shndxdata->d_buf != NULL); size_t sidx = (sym->st_shndx != SHN_XINDEX ? sym->st_shndx : xshndx); + elf_assert (sidx < shnum); sec = shdr_info[sidx].idx; if (sec != 0)