diff options
author | Mark Wielaard <[email protected]> | 2025-02-09 00:07:39 +0100 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2025-02-14 08:55:10 +0100 |
commit | 73db9d2021cab9e23fd734b0a76a612d52a6f1db (patch) | |
tree | e9890494973df6603db561b3e34417acb1215f46 | |
parent | b38e562a4c907e08171c76b8b2def8464d5a104a (diff) |
readelf: Skip trying to uncompress sections without a name
When combining eu-readelf -z with -x or -p to dump the data or strings
in an (corrupted ELF) unnamed numbered section eu-readelf could crash
trying to check whether the section name starts with .zdebug. Fix this
by skipping sections without a name.
* src/readelf.c (dump_data_section): Don't try to gnu decompress a
section without a name.
(print_string_section): Likewise.
https://sourceware.org/bugzilla/show_bug.cgi?id=32656
Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r-- | src/readelf.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/readelf.c b/src/readelf.c index 21b92a08..da379216 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -13327,7 +13327,7 @@ dump_data_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name) _("Couldn't uncompress section"), elf_ndxscn (scn)); } - else if (startswith (name, ".zdebug")) + else if (name && startswith (name, ".zdebug")) { if (elf_compress_gnu (scn, 0, 0) < 0) printf ("WARNING: %s [%zd]\n", @@ -13378,7 +13378,7 @@ print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name) _("Couldn't uncompress section"), elf_ndxscn (scn)); } - else if (startswith (name, ".zdebug")) + else if (name && startswith (name, ".zdebug")) { if (elf_compress_gnu (scn, 0, 0) < 0) printf ("WARNING: %s [%zd]\n", |