summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2015-06-18 10:38:12 +0200
committerMark Wielaard <[email protected]>2015-06-19 12:20:56 +0200
commit1dcbe0c59a72eb1c6908ebce5209683769526349 (patch)
tree8c9a68e35c80eece04f9469ec619d923b279d736
parent0d01165e665fd51da69de1aebed64fdb5b5f04e1 (diff)
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 <[email protected]>
-rw-r--r--libdw/ChangeLog6
-rw-r--r--libdw/dwarf_getmacros.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 487e34a7..577de920 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-18 Mark Wielaard <[email protected]>
+
+ * dwarf_getmacros.c (get_macinfo_table): Return NULL when
+ dwarf_formudata reports an error.
+ (get_table_for_offset): Likewise.
+
2015-06-08 Mark Wielaard <[email protected]>
* dwarf_getsrclines.c (read_srclines): Initialize dirarray early.
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index 740368ef..a326e586 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