From: Maks Mishin <maks.mishinfz@gmail.com>
To: elfutils-devel@sourceware.org
Cc: Maks Mishin <maks.mishinFZ@gmail.com>
Subject: [PATCH] readelf: Fix deref-of-null in dump_archive_index()
Date: Mon, 1 Apr 2024 19:42:31 +0300 [thread overview]
Message-ID: <20240401164231.23940-1-maks.mishinFZ@gmail.com> (raw)
Pointer, returned from function 'elf_getarhdr' ar readelf.c:13551,
may be NULL and is dereferenced at readelf.c:13553.
Found by RASU JCS.
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
src/readelf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/readelf.c b/src/readelf.c
index 0e931184..a650c0b9 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -13549,6 +13549,12 @@ dump_archive_index (Elf *elf, const char *fname)
as_off, fname, elf_errmsg (-1));
const Elf_Arhdr *h = elf_getarhdr (subelf);
+ if (h == NULL)
+ {
+ printf ("cannot get archive header in '%s': %s\n",
+ fname, elf_errmsg (-1));
+ return;
+ }
printf (_("Archive member '%s' contains:\n"), h->ar_name);
--
2.30.2
reply other threads:[~2024-04-01 16:42 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=20240401164231.23940-1-maks.mishinFZ@gmail.com \
--to=maks.mishinfz@gmail.com \
--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).