libdw: Check end of attributes list consistently.
authorMark Wielaard <mark@klomp.org>
Sat, 18 Aug 2018 17:51:27 +0000 (19:51 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 18 Aug 2018 18:07:06 +0000 (20:07 +0200)
commit6983e59b727458a6c64d9659c85f08218bc4fcda
treed26cadddf19e0e5bd7e2dc22beeddac6b15eb279
parent29e31978ba51c1051743a503ee325b5ebc03d7e9
libdw: Check end of attributes list consistently.

dwarf_child (__libdw_find_attr), dwarf_getabbrevattr[_data] and
dwarf_getattrs all assume the end of the attribute list is when
both the name (code) and form of the attribute are zero.

dwarf_getabbrev (__libdw_getabbrev) and dwarf_hasattr assume the
end of the attribute list is when either the name (code) or the
form of the attribute is zero.

The DWARF spec says: "The series of attribute specifications ends
with an entry containing 0 for the name and 0 for the form." So
the first check is correct.

Make sure dwarf_getabbrev and dwarf_hasattr use the same check.
This is important since all other functions expect dwarf_getabbrev
(__libdw_getabbrev) to have done a data sanity check of the attribute.
So if the ending condition is different it could cause a crash.

https://sourceware.org/bugzilla/show_bug.cgi?id=23529

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