summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2025-04-30 00:22:59 +0200
committerMark Wielaard <[email protected]>2025-04-30 00:22:59 +0200
commit50586ba4a99c06674962fe3bdd685088ab6808e1 (patch)
treeb8869125f1470e43e20bedcd63e526d45221a059
parent56e7a862d82e646bae79706343afa5f7800e2be1 (diff)
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 <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r--src/unstrip.c6
1 files changed, 6 insertions, 0 deletions
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