libdw: Return an error in dwarf_getlocation_attr for missing .debug_addr.
authorMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 00:11:44 +0000 (02:11 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 10 Jun 2018 09:03:31 +0000 (11:03 +0200)
commitc5fdb8e5e0be9a507766a58f3c27c57703f369a9
tree2ae1bc365feec1b904e07e12e74d2bb709fc663e
parent725bcd0a0acc9736e4d6312ccb630f98a0fea1a9
libdw: Return an error in dwarf_getlocation_attr for missing .debug_addr.

When constructing a "fake" Dwarf_Attribute for DW_OP_GNU_const_index,
DW_OP_constx, DW_OP_GNU_addr_index or DW_OP_addrx, we would create a
fake attribute pointing to the actual data in the .debug_addr section.

We would even do that if there was no .debug_addr section assuming
dwarf_formaddr or dwarf_formudata would generate an error. But when
there is no .debug_addr there is also no fake_addr_cu, so the
dwarf_form* functions cannot check the value is correct (and crash).

Fix by returning an error early from dwarf_getlocation_attr indicating
bad DWARF data.

Found by the afl fuzzer running on the varlocs testcase.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_getlocation_attr.c