summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-17 22:53:13 +0100
committerMark Wielaard <mark@klomp.org>2021-12-18 02:23:44 +0100
commitee99a6ec16f52fc31f322f7ec1abfedf400a09fa (patch)
tree6d43dd53325a68115108a9caf54a03be7e19548e /libdwfl
parenttests: Use /bin/sh instead of /bin/ls as always there binary (diff)
downloadelfutils-ee99a6ec16f52fc31f322f7ec1abfedf400a09fa.tar.gz
elfutils-ee99a6ec16f52fc31f322f7ec1abfedf400a09fa.tar.bz2
elfutils-ee99a6ec16f52fc31f322f7ec1abfedf400a09fa.tar.xz
libdwfl: Make sure there is at least one dynamic entry
The buffer read in needs to contain room for at least one Elf32_Dyn or Elf64_Dyn entry. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/link_map.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index f849b816..d4eee639 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
12021-12-16 Mark Wielaard <mark@klomp.org>
2
3 * link_map.c (dwfl_link_map_report): Make sure dyn_filesz / entsize is
4 non-zero.
5
12021-12-08 Mark Wielaard <mark@klomp.org> 62021-12-08 Mark Wielaard <mark@klomp.org>
2 7
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Add 8 * dwfl_segment_report_module.c (dwfl_segment_report_module): Add
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 82df7b69..177ad9a5 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -1017,6 +1017,11 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
1017 in.d_size. The data might have been truncated. */ 1017 in.d_size. The data might have been truncated. */
1018 if (dyn_filesz > in.d_size) 1018 if (dyn_filesz > in.d_size)
1019 dyn_filesz = in.d_size; 1019 dyn_filesz = in.d_size;
1020 if (dyn_filesz / entsize == 0)
1021 {
1022 __libdwfl_seterrno (DWFL_E_BADELF);
1023 return false;
1024 }
1020 void *buf = malloc (dyn_filesz); 1025 void *buf = malloc (dyn_filesz);
1021 Elf32_Dyn (*d32)[dyn_filesz / sizeof (Elf32_Dyn)] = buf; 1026 Elf32_Dyn (*d32)[dyn_filesz / sizeof (Elf32_Dyn)] = buf;
1022 Elf64_Dyn (*d64)[dyn_filesz / sizeof (Elf64_Dyn)] = buf; 1027 Elf64_Dyn (*d64)[dyn_filesz / sizeof (Elf64_Dyn)] = buf;