From: Mark Wielaard Date: Thu, 18 Jun 2015 08:38:12 +0000 (+0200) Subject: libdw: Detect dwarf_formudata errors in dwarf_getmacros. X-Git-Tag: elfutils-0.163~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dcbe0c59a72eb1c6908ebce5209683769526349;p=thirdparty%2Felfutils.git libdw: Detect dwarf_formudata errors in dwarf_getmacros. dwarf_formudata can return an error for bad DWARF. Don't ignore it. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 487e34a70..577de9202 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2015-06-18 Mark Wielaard + + * dwarf_getmacros.c (get_macinfo_table): Return NULL when + dwarf_formudata reports an error. + (get_table_for_offset): Likewise. + 2015-06-08 Mark Wielaard * dwarf_getsrclines.c (read_srclines): Initialize dirarray early. diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c index 740368ef0..a326e5865 100644 --- a/libdw/dwarf_getmacros.c +++ b/libdw/dwarf_getmacros.c @@ -125,7 +125,8 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie) = INTUSE(dwarf_attr) (cudie, DW_AT_stmt_list, &attr_mem); Dwarf_Off line_offset = (Dwarf_Off) -1; if (attr != NULL) - INTUSE(dwarf_formudata) (attr, &line_offset); + if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0)) + return NULL; Dwarf_Macro_Op_Table *table = libdw_alloc (dbg, Dwarf_Macro_Op_Table, macinfo_data_size, 1); @@ -178,7 +179,8 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Attribute attr_mem, *attr = INTUSE(dwarf_attr) (cudie, DW_AT_stmt_list, &attr_mem); if (attr != NULL) - INTUSE(dwarf_formudata) (attr, &line_offset); + if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0)) + return NULL; } /* """The macinfo entry types defined in this standard may, but