public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: Don't install an Elf handle in a Dwfl_Module twice
@ 2021-12-08 22:59 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2021-12-08 22:59 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

dwfl_segment_report_module can be called with the same module
name, start and end address twice (probably because of a corrupt
core file). In that case don't override the main.elf handle if
it already exists.

https://sourceware.org/bugzilla/show_bug.cgi?id=28655

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog                    | 5 +++++
 libdwfl/dwfl_segment_report_module.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5e25c1b0..a896c2b4 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2021-12-08  Mark Wielaard  <mark@klomp.org>
+
+	* dwfl_segment_report_module.c (dwfl_segment_report_module): Check
+	Dwfl_Module isn't associated with an Elf before installing it.
+
 2021-12-08  Mark Wielaard  <mark@klomp.org>
 
 	* dwfl_segment_report_module.c (dwfl_segment_report_module): Don't
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 5efc9d6a..8d749f4c 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -959,7 +959,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 	elf->flags |= ELF_F_MALLOCED;
     }
 
-  if (elf != NULL)
+  if (elf != NULL && mod->main.elf == NULL)
     {
       /* Install the file in the module.  */
       mod->main.elf = elf;
-- 
2.30.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-08 23:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 22:59 [PATCH] libdwfl: Don't install an Elf handle in a Dwfl_Module twice Mark Wielaard

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).