]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
strip: Files with symbols referring to non-existing sections are illformed
authorMark Wielaard <mark@klomp.org>
Wed, 27 Mar 2019 20:54:06 +0000 (21:54 +0100)
committerMark Wielaard <mark@klomp.org>
Wed, 27 Mar 2019 20:57:21 +0000 (21:57 +0100)
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 <mark@klomp.org>
src/ChangeLog
src/strip.c

index 0544fceba36bafb3569c5e7aef00db5e4d5a9927..fb1ac096487c6d9d8f4f1e812f8a1625aa570e1b 100644 (file)
@@ -1,3 +1,7 @@
+2019-03-27  Mark Wielaard  <mark@klomp.org>
+
+       * strip (handle_elf): Assert that symbol section number exists.
+
 2019-01-24  Mark Wielaard  <mark@klomp.org>
 
        * strip.c (handle_elf): Fix check test for SHN_XINDEX symbol.
index a73009d980e66261f4bcc5f38ee7c1257e55cd49..4cd87506e8213fe68b5c40a258113eabbd189344 100644 (file)
@@ -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)