From: Mark Wielaard Date: Tue, 29 Apr 2025 22:22:59 +0000 (+0200) Subject: unstrip: Check symtab and strtab sections have data before use. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50586ba4a99c06674962fe3bdd685088ab6808e1;p=thirdparty%2Felfutils.git unstrip: Check symtab and strtab sections have data before use. * src/unstrip.c (copy_elided_sections): Check elf_getdata result for symtab and strtab sections. Suggested-by: Anton Moryakov Signed-off-by: Mark Wielaard --- diff --git a/src/unstrip.c b/src/unstrip.c index d70053de..0ae76f77 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -1946,7 +1946,13 @@ more sections in stripped file than debug file -- arguments reversed?")); /* Now we are ready to write the new symbol table. */ symdata = elf_getdata (unstripped_symtab, NULL); + if (symdata == NULL) + error_exit (0, "Failed to get data from symbol table: %s", + elf_errmsg (-1)); symstrdata = elf_getdata (unstripped_strtab, NULL); + if (symstrdata == NULL) + error_exit (0, "Failed to get data from symbol string table: %s", + elf_errmsg (-1)); Elf_Data *shndxdata = NULL; /* XXX */ /* If symtab and the section header table share the string table