From 50d5b2cbfe7e2d790c91e6f799a59c70ab4839ff Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Feb 2014 11:26:27 -0800 Subject: libdw: Read DW_AT_decl_file/line/column as unsigned Section 2.14 of the DWARF v3 & v4 standards specifies that all three declaration coordinates are unsigned integer constants. DWARF v2 did not specify signedness. Now dwarf_decl_* use dwarf_formudata to read these values. Also, an assertion on the range of line/column is now a handled error, setting DWARF_E_INVALID_DWARF for values greater than INT_MAX. Signed-off-by: Josh Stone --- libdw/ChangeLog | 6 ++++++ libdw/dwarf_decl_file.c | 4 ++-- libdw/dwarf_decl_line.c | 13 +++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 6e779c8e..19a2a505 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2014-02-05 Josh Stone + + * dwarf_decl_file.c (dwarf_decl_file): Read the idx as unsigned. + * dwarf_decl_line.c (__libdw_attr_intval): Read the line/column as + unsigned. Change the range assert to DWARF_E_INVALID_DWARF. + 2013-12-30 Mark Wielaard * libdw.map (ELFUTILS_0.158): Add dwfl_core_file_attach and diff --git a/libdw/dwarf_decl_file.c b/libdw/dwarf_decl_file.c index c18aceb3..5657132f 100644 --- a/libdw/dwarf_decl_file.c +++ b/libdw/dwarf_decl_file.c @@ -40,9 +40,9 @@ const char * dwarf_decl_file (Dwarf_Die *die) { Dwarf_Attribute attr_mem; - Dwarf_Sword idx = 0; + Dwarf_Word idx = 0; - if (INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr_integrate) + if (INTUSE(dwarf_formudata) (INTUSE(dwarf_attr_integrate) (die, DW_AT_decl_file, &attr_mem), &idx) != 0) return NULL; diff --git a/libdw/dwarf_decl_line.c b/libdw/dwarf_decl_line.c index 5b6db5f5..80fae6c9 100644 --- a/libdw/dwarf_decl_line.c +++ b/libdw/dwarf_decl_line.c @@ -50,15 +50,20 @@ int internal_function __libdw_attr_intval (Dwarf_Die *die, int *linep, int attval) { Dwarf_Attribute attr_mem; - Dwarf_Sword line; + Dwarf_Word line; - int res = INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr_integrate) + int res = INTUSE(dwarf_formudata) (INTUSE(dwarf_attr_integrate) (die, attval, &attr_mem), &line); if (res == 0) { - assert (line >= 0 && line <= INT_MAX); - *linep = line; + if (line > INT_MAX) + { + __libdw_seterrno (DWARF_E_INVALID_DWARF); + res = -1; + } + else + *linep = line; } return res; -- cgit v1.2.1