summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-17 23:51:35 +0100
committerMark Wielaard <mark@klomp.org>2021-12-18 02:23:44 +0100
commitcdf407ef36378ba623c97f9c5c454666f45771fd (patch)
tree6a452ee7954503bdd9e533da66912d78fac5b72e /libdwfl
parentlibdwfl: Make sure there is at least one dynamic entry (diff)
downloadelfutils-cdf407ef36378ba623c97f9c5c454666f45771fd.tar.gz
elfutils-cdf407ef36378ba623c97f9c5c454666f45771fd.tar.bz2
elfutils-cdf407ef36378ba623c97f9c5c454666f45771fd.tar.xz
libdwfl: Make sure there is at least one phdr
The buffer read in needs to contain room for at least one Phdr. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog4
-rw-r--r--libdwfl/link_map.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d4eee639..8760b1ef 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,9 @@
12021-12-16 Mark Wielaard <mark@klomp.org> 12021-12-16 Mark Wielaard <mark@klomp.org>
2 2
3 * link_map.c (dwfl_link_map_report): Make sure phnum is non-zero.
4
52021-12-16 Mark Wielaard <mark@klomp.org>
6
3 * link_map.c (dwfl_link_map_report): Make sure dyn_filesz / entsize is 7 * link_map.c (dwfl_link_map_report): Make sure dyn_filesz / entsize is
4 non-zero. 8 non-zero.
5 9
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 177ad9a5..c4f79f11 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -890,6 +890,11 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
890 { 890 {
891 nbytes = in.d_size; 891 nbytes = in.d_size;
892 phnum = nbytes / phent; 892 phnum = nbytes / phent;
893 if (phnum == 0)
894 {
895 __libdwfl_seterrno (DWFL_E_BADELF);
896 return false;
897 }
893 } 898 }
894 void *buf = malloc (nbytes); 899 void *buf = malloc (nbytes);
895 Elf32_Phdr (*p32)[phnum] = buf; 900 Elf32_Phdr (*p32)[phnum] = buf;