public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4.
@ 2018-06-13 23:25 Mark Wielaard
  2018-06-16 23:07 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-06-13 23:25 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4.
  2018-06-13 23:25 [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4 Mark Wielaard
@ 2018-06-16 23:07 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-06-16 23:07 UTC (permalink / raw)
  To: elfutils-devel

On Thu, 2018-06-14 at 01:24 +0200, Mark Wielaard wrote:
> 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.

Pushed to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-16 23:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13 23:25 [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4 Mark Wielaard
2018-06-16 23:07 ` 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).