summaryrefslogtreecommitdiff
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2019-01-20 23:05:56 +0100
committerMark Wielaard <mark@klomp.org>2019-01-22 17:42:42 +0100
commitda5c5336a1eaf519de246f7d9f0f5585e1d4ac59 (patch)
treef7b83fc5ab159bed12cee6cea97a542bbd01a3fc /libdwfl
parentde01cc6f9446187d69b9748bb3636361c79e77a4 (diff)
downloadelfutils-da5c5336a1eaf519de246f7d9f0f5585e1d4ac59.tar.gz
libdwfl: Sanity check partial core file dyn data read.
When reading the dyn data from the core file check if we got everything, or just part of the data. https://sourceware.org/bugzilla/show_bug.cgi?id=24103 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index c295fa7d..de45e7f1 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-20 Mark Wielaard <mark@klomp.org>
+
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): Check
+ dyn_filesz vs dyn_data_size after read_portion call.
+
2019-01-16 Mark Wielaard <mark@klomp.org>
* linux-core-attach.c (core_next_thread): Pass desc to ebl_core_note.
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 0d633ffe..f6ad39b3 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -783,6 +783,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
if (dyn_filesz != 0 && dyn_filesz % dyn_entsize == 0
&& ! read_portion (&dyn_data, &dyn_data_size, dyn_vaddr, dyn_filesz))
{
+ /* dyn_data_size will be zero if we got everything from the initial
+ buffer, otherwise it will be the size of the new buffer that
+ could be read. */
+ if (dyn_data_size != 0)
+ dyn_filesz = dyn_data_size;
+
void *dyns = malloc (dyn_filesz);
Elf32_Dyn (*d32)[dyn_filesz / sizeof (Elf32_Dyn)] = dyns;
Elf64_Dyn (*d64)[dyn_filesz / sizeof (Elf64_Dyn)] = dyns;