libdw: Don't assert in __libdw_getabbrev when seeing bad DWARF.
authorMark Wielaard <mjw@redhat.com>
Sun, 23 Nov 2014 22:13:55 +0000 (23:13 +0100)
committerMark Wielaard <mjw@redhat.com>
Wed, 26 Nov 2014 19:25:49 +0000 (20:25 +0100)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_getabbrev.c

index 9ceb527..a3f204a 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-23  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_getabbrev.c (__libdw_getabbrev): Don't assert on bad DWARF.
+       Set libdw errno and return NULL.
+
 2014-11-24  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf.h (DW_LANG_C_plus_plus_11): Added.
index 87d89c1..6bb2bd7 100644 (file)
@@ -1,5 +1,5 @@
 /* Get abbreviation at given offset.
-   Copyright (C) 2003, 2004, 2005, 2006 Red Hat, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2014 Red Hat, Inc.
    This file is part of elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -31,7 +31,6 @@
 # include <config.h>
 #endif
 
-#include <assert.h>
 #include <dwarf.h>
 #include "libdwP.h"
 
@@ -97,7 +96,13 @@ __libdw_getabbrev (dbg, cu, offset, lengthp, result)
     {
       foundit = true;
 
-      assert (abb->offset == offset);
+      if (unlikely (abb->offset != offset))
+       {
+         /* A duplicate abbrev code at a different offset,
+            that should never happen.  */
+         __libdw_seterrno (DWARF_E_INVALID_DWARF);
+         return NULL;
+       }
 
       /* If the caller doesn't need the length we are done.  */
       if (lengthp == NULL)