]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
unstrip: Check symtab and strtab sections have data before use.
authorMark Wielaard <mark@klomp.org>
Tue, 29 Apr 2025 22:22:59 +0000 (00:22 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 29 Apr 2025 22:22:59 +0000 (00:22 +0200)
* src/unstrip.c (copy_elided_sections): Check elf_getdata result
for symtab and strtab sections.

Suggested-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
src/unstrip.c

index d70053def292b02944936bcccc3ee61190e76bc6..0ae76f77e9ae86aefa91ce6d991587a298a58213 100644 (file)
@@ -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