diff options
author | Josh Stone <jistone@redhat.com> | 2014-02-05 11:26:27 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2014-02-05 11:26:27 -0800 |
commit | 50d5b2cbfe7e2d790c91e6f799a59c70ab4839ff (patch) | |
tree | 6c57ab8f62b5c59b7c469d39d6acfa3f91adee48 /libdw | |
parent | 27ffb08c789ca9c4b2635ca89b4004b324fb4ea4 (diff) | |
download | elfutils-50d5b2cbfe7e2d790c91e6f799a59c70ab4839ff.tar.gz |
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 <jistone@redhat.com>
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 6 | ||||
-rw-r--r-- | libdw/dwarf_decl_file.c | 4 | ||||
-rw-r--r-- | 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 <jistone@redhat.com> + + * 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 <mjw@redhat.com> * 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; |