]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Check DIE address fall inside the CU before reading abbrev code.
authorMark Wielaard <mark@klomp.org>
Thu, 7 Jun 2018 14:57:23 +0000 (16:57 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 9 Jun 2018 07:57:53 +0000 (09:57 +0200)
The afl fuzzer found a case where we tried reading an uleb for the DIE
abbrev code without properly checking the DIE address is inside the CU.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/libdwP.h

index b000492e3b1c8a9ba013006ca50205075bd6165f..b569393044f1307292b83de6e108fc659807c6ea 100644 (file)
@@ -1,3 +1,7 @@
+2018-06-06  Mark Wielaard  <mark@klomp.org>
+
+       * libdwP.h (__libdw_dieabbrev): Check DIE addr falls in cu.
+
 2018-06-06  Mark Wielaard  <mark@klomp.org>
 
        * dwarf_getlocation_die.c (dwarf_getlocation_die): Check offset
index 1c8dd0d2aa3d957e7d081204533424516bb709a6..3d8e145a9d1c705a6f4695119e0c44315aa5e0ae 100644 (file)
@@ -653,7 +653,7 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
       /* Get the abbreviation code.  */
       unsigned int code;
       const unsigned char *addr = die->addr;
-      if (die->cu == NULL)
+      if (die->cu == NULL || addr >= (const unsigned char *) die->cu->endp)
        return DWARF_END_ABBREV;
       get_uleb128 (code, addr, die->cu->endp);
       if (readp != NULL)