]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Sanity check end of section against cu_data () of die->cu.
authorMark Wielaard <mjw@redhat.com>
Tue, 26 Apr 2011 15:15:28 +0000 (17:15 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 26 Apr 2011 15:15:28 +0000 (17:15 +0200)
A Dwarf_CU can come from either the debug_info compile unit or a
debug_type type unit section. Use the correct one for sanity checking
whether we have a truncated section.

libdw/ChangeLog
libdw/dwarf_child.c

index 0b1746185696365370ee2b9fd869af0161db82cc..8febd4287ffe7cda82af67f6f10cce1345930a13 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-26  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_child (dwarf_child): Sanity check end of section against
+       cu_data () of die->cu.
+
 2011-03-22  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf.h: Add DW_TAG_GNU_call_site,
index 1ec3704e4e12de1fececdbedd565053e05013c49..0c2df0041b876aa8b43828674370145fe98c8488 100644 (file)
@@ -177,13 +177,13 @@ dwarf_child (die, result)
 
   /* RESULT can be the same as DIE.  So preserve what we need.  */
   struct Dwarf_CU *cu = die->cu;
+  Elf_Data *cu_sec = cu_data (cu);
 
   /* It's kosher (just suboptimal) to have a null entry first thing (7.5.3).
      So if this starts with ULEB128 of 0 (even with silly encoding of 0),
      it is a kosher null entry and we do not really have any children.  */
   const unsigned char *code = addr;
-  const unsigned char *endp = (cu->dbg->sectiondata[IDX_debug_info]->d_buf
-                              + cu->dbg->sectiondata[IDX_debug_info]->d_size);
+  const unsigned char *endp = (cu_sec->d_buf + cu_sec->d_size);
   while (1)
     {
       if (unlikely (code >= endp)) /* Truncated section.  */