summaryrefslogtreecommitdiffstats
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-06-07 16:57:23 +0200
committerMark Wielaard <mark@klomp.org>2018-06-09 09:57:53 +0200
commit92b7bbded238b93fc1021bf8613f2cc4ab59e31a (patch)
tree73b29c4cb6262a1754d46261e1fbfd7b052a8c41 /libdw
parent64024753424afcd263f5022446be15a920161bd0 (diff)
libdw: Check DIE address fall inside the CU before reading abbrev code.
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>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog4
-rw-r--r--libdw/libdwP.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index b000492e..b5693930 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
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
falls inside cu data.
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 1c8dd0d2..3d8e145a 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -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)