]> git.ipfire.org Git - thirdparty/elfutils.git/commit
strip: Verify symbol table is a real symbol table
authorMark Wielaard <mark@klomp.org>
Thu, 13 Feb 2025 13:59:34 +0000 (14:59 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 14 Feb 2025 07:55:10 +0000 (08:55 +0100)
commitfbf1df9ca286de3323ae541973b08449f8d03aba
tree166efda2badf0f46af9456d3d69001e22f0caa98
parent73db9d2021cab9e23fd734b0a76a612d52a6f1db
strip: Verify symbol table is a real symbol table

We didn't check the symbol table referenced from the relocation table
was a real symbol table. This could cause a crash if that section
happened to be an SHT_NOBITS section without any data. Fix this by
adding an explicit check.

       * src/strip.c (INTERNAL_ERROR_MSG): New macro that takes a
       message string to display.
       (INTERNAL_ERROR): Use INTERNAL_ERROR_MSG with elf_errmsg (-1).
       (remove_debug_relocations): Check the sh_link referenced
       section is real and isn't a SHT_NOBITS section.

https://sourceware.org/bugzilla/show_bug.cgi?id=32673

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/strip.c