From: Mark Wielaard Date: Wed, 8 Dec 2021 22:44:34 +0000 (+0100) Subject: libdwfl: Don't install an Elf handle in a Dwfl_Module twice X-Git-Tag: elfutils-0.187~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98e7adf70896ac179258d41c2aac38e9e91614bb;p=platform%2Fupstream%2Felfutils.git libdwfl: Don't install an Elf handle in a Dwfl_Module twice 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 --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 76e0899..1f593ac 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,5 +1,10 @@ 2021-12-08 Mark Wielaard + * 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 + * dwfl_segment_report_module.c (dwfl_segment_report_module): Don't trust e_shentsize. diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index be0aff7..f4acfe5 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -963,7 +963,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;