From 50586ba4a99c06674962fe3bdd685088ab6808e1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 30 Apr 2025 00:22:59 +0200 Subject: [PATCH] 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 --- src/unstrip.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unstrip.c b/src/unstrip.c index d70053def..0ae76f77e 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 -- 2.47.2