From: Mark Wielaard Date: Fri, 17 Dec 2021 22:51:35 +0000 (+0100) Subject: libdwfl: Make sure there is at least one phdr X-Git-Tag: elfutils-0.187~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cdf407ef36378ba623c97f9c5c454666f45771fd;p=thirdparty%2Felfutils.git 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 --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index d4eee6393..8760b1ef8 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2021-12-16 Mark Wielaard + + * link_map.c (dwfl_link_map_report): Make sure phnum is non-zero. + 2021-12-16 Mark Wielaard * link_map.c (dwfl_link_map_report): Make sure dyn_filesz / entsize is diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 177ad9a5f..c4f79f112 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, { nbytes = in.d_size; phnum = nbytes / phent; + if (phnum == 0) + { + __libdwfl_seterrno (DWFL_E_BADELF); + return false; + } } void *buf = malloc (nbytes); Elf32_Phdr (*p32)[phnum] = buf;