From: Mark Wielaard Date: Sun, 23 Nov 2014 22:13:55 +0000 (+0100) Subject: libdw: Don't assert in __libdw_getabbrev when seeing bad DWARF. X-Git-Tag: elfutils-0.161~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04b61f8601bf9267976cc4461091622ffdbadf67;p=thirdparty%2Felfutils.git libdw: Don't assert in __libdw_getabbrev when seeing bad DWARF. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 9ceb52725..a3f204a72 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2014-11-23 Mark Wielaard + + * dwarf_getabbrev.c (__libdw_getabbrev): Don't assert on bad DWARF. + Set libdw errno and return NULL. + 2014-11-24 Mark Wielaard * dwarf.h (DW_LANG_C_plus_plus_11): Added. diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c index 87d89c1b8..6bb2bd760 100644 --- a/libdw/dwarf_getabbrev.c +++ b/libdw/dwarf_getabbrev.c @@ -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 , 2003. @@ -31,7 +31,6 @@ # include #endif -#include #include #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)