public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] readelf: Check gelf_getdyn doesn't return NULL
Date: Thu,  3 Nov 2022 14:18:27 +0100	[thread overview]
Message-ID: <20221103131827.18315-1-mark@klomp.org> (raw)

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


                 reply	other threads:[~2022-11-03 13:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221103131827.18315-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).