public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Don't assert when addr_size or ref_size is not 4 or 8 in print_ops.
@ 2014-12-15 18:08 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2014-12-15 18:08 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

Just report invalid data and continue.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog |  5 +++++
 src/readelf.c | 23 ++++++++---------------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 182c9cd..08f9ee4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2014-12-15  Mark Wielaard  <mjw@redhat.com>
 
+	* readelf.c (print_ops): Don't assert when addr_size or ref_size
+	is not 4 or 8, just report invalid data.
+
+2014-12-15  Mark Wielaard  <mjw@redhat.com>
+
 	* readelf.c (print_gdb_index_section): Add more bounds checks.
 
 2014-12-15  Mark Wielaard  <mjw@redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index 41239bc..aa85d73 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -3981,11 +3981,10 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
 	  NEED (addrsize);
 	  if (addrsize == 4)
 	    addr = read_4ubyte_unaligned (dbg, data);
+	  else if (addrsize == 8)
+	    addr = read_8ubyte_unaligned (dbg, data);
 	  else
-	    {
-	      assert (addrsize == 8);
-	      addr = read_8ubyte_unaligned (dbg, data);
-	    }
+	    goto invalid;
 	  data += addrsize;
 	  CONSUME (addrsize);
 
@@ -3999,16 +3998,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
 
 	case DW_OP_call_ref:
 	  /* Offset operand.  */
-	  if (ref_size == 0)
+	  if (ref_size != 4 && ref_size != 8)
 	    goto invalid; /* Cannot be used in CFA.  */
 	  NEED (ref_size);
 	  if (ref_size == 4)
 	    addr = read_4ubyte_unaligned (dbg, data);
 	  else
-	    {
-	      assert (ref_size == 8);
-	      addr = read_8ubyte_unaligned (dbg, data);
-	    }
+	    addr = read_8ubyte_unaligned (dbg, data);
 	  data += ref_size;
 	  CONSUME (ref_size);
 
@@ -4206,16 +4202,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
 	case DW_OP_GNU_implicit_pointer:
 	  /* DIE offset operand.  */
 	  start = data;
-	  NEED (ref_size + 1);
-	  if (ref_size == 0)
+	  NEED (ref_size);
+	  if (ref_size != 4 && ref_size != 8)
 	    goto invalid; /* Cannot be used in CFA.  */
 	  if (ref_size == 4)
 	    addr = read_4ubyte_unaligned (dbg, data);
 	  else
-	    {
-	      assert (ref_size == 8);
-	      addr = read_8ubyte_unaligned (dbg, data);
-	    }
+	    addr = read_8ubyte_unaligned (dbg, data);
 	  data += ref_size;
 	  /* Byte offset operand.  */
 	  NEED (1);
-- 
1.8.3.1


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

only message in thread, other threads:[~2014-12-15 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-15 18:08 [PATCH] readelf: Don't assert when addr_size or ref_size is not 4 or 8 in print_ops 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).