[PATCH] libdwfl: Make sure we know the phdr entry size before searching phdrs.

Mark Wielaard mark@klomp.org
Wed Dec 8 19:52:45 GMT 2021


Without the program header entry size we cannot search through the
phdrs.

https://sourceware.org/bugzilla/show_bug.cgi?id=28657

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog  | 4 ++++
 libdwfl/link_map.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 852b199a..8dd595f8 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2021-12-08  Mark Wielaard  <mark@klomp.org>
+
+	* link_map.c (dwfl_link_map_report): Make sure phent != 0.
+
 2021-12-08  Mark Wielaard  <mark@klomp.org>
 
 	* link_map.c (dwfl_link_map_report): Limit malloc size to max
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 1c298a8e..623b3062 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -784,7 +784,7 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
       GElf_Xword dyn_filesz = 0;
       GElf_Addr dyn_bias = (GElf_Addr) -1;
 
-      if (phdr != 0 && phnum != 0)
+      if (phdr != 0 && phnum != 0 && phent != 0)
 	{
 	  Dwfl_Module *phdr_mod;
 	  int phdr_segndx = INTUSE(dwfl_addrsegment) (dwfl, phdr, &phdr_mod);
-- 
2.30.2



More information about the Elfutils-devel mailing list