diff options
author | Aaron Merey <amerey@redhat.com> | 2023-11-01 16:15:16 -0400 |
---|---|---|
committer | Aaron Merey <amerey@redhat.com> | 2023-11-01 19:29:16 -0400 |
commit | a34c5faad861efdd26d1c52b4f8d9d4077e03131 (patch) | |
tree | 525d3fa1e18c6134f3e37f52d90520de838dc502 | |
parent | c112cf0f1975e19a6111f594c0e5c4d2210c0f9a (diff) |
dwfl_offline_section_address: replace asserts with early return
dwfl_offline_section_address asserts that the current module is ET_REL.
A possibly corrupt .gnu_debuglink can cause an abort by calling
dwfl_offline_section_address on an ET_DYN module.
Prevent this abort and similar ones by replacing
dwfl_offline_section_address initial asserts with an early return.
https://sourceware.org/bugzilla/show_bug.cgi?id=30980
Signed-off-by: Aaron Merey <amerey@redhat.com>
-rw-r--r-- | libdwfl/offline.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libdwfl/offline.c b/libdwfl/offline.c index e090b42b..52539fe3 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -50,10 +50,11 @@ dwfl_offline_section_address (Dwfl_Module *mod, const GElf_Shdr *shdr __attribute__ ((unused)), Dwarf_Addr *addr) { - assert (mod->e_type == ET_REL); - assert (shdr->sh_addr == 0); - assert (shdr->sh_flags & SHF_ALLOC); - assert (shndx != 0); + if (mod->e_type != ET_REL + || shdr->sh_addr != 0 + || !(shdr->sh_flags & SHF_ALLOC) + || shndx == 0) + return -1; if (mod->debug.elf == NULL) /* We are only here because sh_addr is zero even though layout is complete. |