This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] readelf: Don't assert when addr_size or ref_size is not 4 or 8 in print_ops.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]