diff options
author | Mark Wielaard <mjw@redhat.com> | 2015-12-01 22:16:00 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2016-01-02 20:37:45 +0100 |
commit | 355b408bb9aa49703544fa4086e1ae463737fcf6 (patch) | |
tree | 9ac6581d1cb66dc4b6c2328c715308db7cfc20af /libdwfl/link_map.c | |
parent | a1372e06a04bad29e8c3c79d95497a8e381f823f (diff) | |
download | elfutils-355b408bb9aa49703544fa4086e1ae463737fcf6.tar.gz |
libdwfl: Don't leak core Elf and core file descriptor from argp-std.
Our argp helper would leak the core Elf and core file descriptor when
given by the user. Store both in the Dwfl as a new Dwfl_User_Core so
they get cleaned up by dwfl_end.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libdwfl/link_map.c')
-rw-r--r-- | libdwfl/link_map.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 13cac529..e73b2195 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -356,8 +356,10 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (name != NULL && name[0] == '\0') name = NULL; - if (iterations == 1 && dwfl->executable_for_core != NULL) - name = dwfl->executable_for_core; + if (iterations == 1 + && dwfl->user_core != NULL + && dwfl->user_core->executable_for_core != NULL) + name = dwfl->user_core->executable_for_core; struct r_debug_info_module *r_debug_info_module = NULL; if (r_debug_info != NULL) @@ -789,7 +791,9 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size, bool in_ok = (*memory_callback) (dwfl, phdr_segndx, &in.d_buf, &in.d_size, phdr, phnum * phent, memory_callback_arg); - if (! in_ok && dwfl->executable_for_core != NULL) + if (! in_ok + && dwfl->user_core != NULL + && dwfl->user_core->executable_for_core != NULL) { /* AUXV -> PHDR -> DYNAMIC Both AUXV and DYNAMIC should be always present in a core file. @@ -797,7 +801,7 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size, EXECUTABLE_FOR_CORE to find where DYNAMIC is located in the core file. */ - int fd = open (dwfl->executable_for_core, O_RDONLY); + int fd = open (dwfl->user_core->executable_for_core, O_RDONLY); Elf *elf; Dwfl_Error error = DWFL_E_ERRNO; if (fd != -1) |