summaryrefslogtreecommitdiffstats
path: root/libdwfl/dwfl_segment_report_module.c
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-19 20:53:34 +0100
committerMark Wielaard <mark@klomp.org>2021-12-19 20:53:34 +0100
commitbc14c148a6ad9b84bda428bd3bc75028515f0151 (patch)
tree61954ad75e010532f4f393cc1835829818a95136 /libdwfl/dwfl_segment_report_module.c
parentlibdwfl: Make sure that ph_buffer_size has room for at least one phdr (diff)
downloadelfutils-bc14c148a6ad9b84bda428bd3bc75028515f0151.tar.gz
elfutils-bc14c148a6ad9b84bda428bd3bc75028515f0151.tar.bz2
elfutils-bc14c148a6ad9b84bda428bd3bc75028515f0151.tar.xz
libdwfl: Make sure dyn_filesz has a sane size
In dwfl_segment_report_module dyn_filesz should be able to hold at least one Elf_Dyn element, and not be larger than possible. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl/dwfl_segment_report_module.c')
-rw-r--r--libdwfl/dwfl_segment_report_module.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 840d6f44..78c70795 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -787,6 +787,9 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
787 if (dyn_data_size != 0) 787 if (dyn_data_size != 0)
788 dyn_filesz = dyn_data_size; 788 dyn_filesz = dyn_data_size;
789 789
790 if ((dyn_filesz / dyn_entsize) == 0
791 || dyn_filesz > (SIZE_MAX / dyn_entsize))
792 goto out;
790 void *dyns = malloc (dyn_filesz); 793 void *dyns = malloc (dyn_filesz);
791 Elf32_Dyn *d32 = dyns; 794 Elf32_Dyn *d32 = dyns;
792 Elf64_Dyn *d64 = dyns; 795 Elf64_Dyn *d64 = dyns;