From: Mark Wielaard Date: Thu, 28 Dec 2017 23:34:14 +0000 (+0100) Subject: libdw: Check there is .debug_info/types section data in __libdw_offdie. X-Git-Tag: elfutils-0.171~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4af2f2ed9269cd8d99d5c1a2c376e817a65e9e28;p=thirdparty%2Felfutils.git libdw: Check there is .debug_info/types section data in __libdw_offdie. If a Dwarf_Die was requested from an offset into a section data that didn't exist we would crash. Crashing is bad even if given bad input. Just return an error in that case. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index eb1cb709e..97155de1f 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2017-12-28 Mark Wielaard + + * dwarf_offdie.c (__libdw_offdie): Check sectiondata exists. + 2017-05-09 Ulf Hermann Mark Wielaard diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c index 15f55c227..883720de2 100644 --- a/libdw/dwarf_offdie.c +++ b/libdw/dwarf_offdie.c @@ -1,5 +1,5 @@ /* Return DIE at given offset. - Copyright (C) 2002-2010 Red Hat, Inc. + Copyright (C) 2002-2010, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2002. @@ -45,7 +45,7 @@ __libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die *result, Elf_Data *const data = dbg->sectiondata[debug_types ? IDX_debug_types : IDX_debug_info]; - if (offset >= data->d_size) + if (data == NULL || offset >= data->d_size) { __libdw_seterrno (DWARF_E_INVALID_DWARF); return NULL;