* [COMMITTED][Bug libdw/30980] dwfl_offline_section_address: replace asserts with early return
@ 2023-11-01 23:32 Aaron Merey
0 siblings, 0 replies; only message in thread
From: Aaron Merey @ 2023-11-01 23:32 UTC (permalink / raw)
To: elfutils-devel; +Cc: Aaron Merey
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>
---
libdwfl/offline.c | 9 +++++----
1 file 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.
--
2.41.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-01 23:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-01 23:32 [COMMITTED][Bug libdw/30980] dwfl_offline_section_address: replace asserts with early return Aaron Merey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).