From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4.
Date: Wed, 13 Jun 2018 23:25:00 -0000 [thread overview]
Message-ID: <20180613232458.19286-1-mark@klomp.org> (raw)
Found by afl-fuzz. When printing a DWARF_FORM_block4 we checked there
were only 2 bytes available (copy/paste from DW_FORM_block2 right
before). Obviously we need at least 4 bytes to read the length of a
DW_FORM_block4.
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 fbbb9acb..5baf82e6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-12 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_form_data): Check we have 4, not 2, bytes
+ available for DW_FORM_block4.
+
2018-06-12 Mark Wielaard <mark@klomp.org>
* print_form_data): Don't increase strreadp after use. Do
diff --git a/src/readelf.c b/src/readelf.c
index 17d91735..3b477ab0 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7907,7 +7907,7 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp,
break;
case DW_FORM_block4:
- if (readendp - readp < 2)
+ if (readendp - readp < 4)
goto invalid_data;
val = read_4ubyte_unaligned_inc (dbg, readp);
if ((size_t) (readendp - readp) < val)
--
2.17.0
next reply other threads:[~2018-06-13 23:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 23:25 Mark Wielaard [this message]
2018-06-16 23:07 ` Mark Wielaard
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=20180613232458.19286-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).