]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Read DW_AT_decl_file/line/column as unsigned
authorJosh Stone <jistone@redhat.com>
Wed, 5 Feb 2014 19:26:27 +0000 (11:26 -0800)
committerJosh Stone <jistone@redhat.com>
Wed, 5 Feb 2014 19:26:27 +0000 (11:26 -0800)
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>
libdw/ChangeLog
libdw/dwarf_decl_file.c
libdw/dwarf_decl_line.c

index 6e779c8e3cb7f4fe225872ad29bcbf6fc1f406ab..19a2a505cdef9cee1c6ee011e548bae32d9d0e09 100644 (file)
@@ -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
index c18aceb389f07b396f4327bd08d18a537cd21948..5657132f4eed42420db4c16aac8755ffa96a8ad5 100644 (file)
@@ -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;
index 5b6db5f5cd11029c5d032a6f0a7d6d93ce541984..80fae6c900175fa7c6f157cd3d3d2145a5a865a7 100644 (file)
@@ -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;