public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] readelf: Check gelf_getdyn doesn't return NULL
@ 2022-11-03 13:18 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2022-11-03 13:18 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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

diff --git a/src/ChangeLog b/src/ChangeLog
index 0c5ab37e..66428b70 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2022-11-03  Mark Wielaard  <mark@klomp.org>
+
+	* readelf.c (get_dynscn_addrs): Check gelf_getdyn doesn't
+	return NULL.
+
 2022-11-03  Mark Wielaard  <mark@klomp.org>
 
 	* readelf.c (handle_dynamic): Check phdr != NULL when
diff --git a/src/readelf.c b/src/readelf.c
index e721a209..3dafb041 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4910,7 +4910,7 @@ get_dynscn_addrs(Elf *elf, GElf_Phdr *phdr, GElf_Addr addrs[i_max])
     GElf_Dyn dyn_mem;
     GElf_Dyn *dyn = gelf_getdyn(data, dyn_idx, &dyn_mem);
     /* DT_NULL Marks end of dynamic section.  */
-    if (dyn->d_tag == DT_NULL)
+    if (dyn == NULL || dyn->d_tag == DT_NULL)
       break;
 
     switch (dyn->d_tag) {
-- 
2.18.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-03 13:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 13:18 [COMMITTED] readelf: Check gelf_getdyn doesn't return NULL Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).