This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] libdw: Make sure end of next cu doesn't overflow section data size.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 12 Dec 2014 00:25:16 +0100
- Subject: [PATCH] libdw: Make sure end of next cu doesn't overflow section data size.
An invalid or trucated debug info/type section could cause the cu endp
to point beyond the end of section data.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libdw/ChangeLog | 4 ++++
libdw/libdw_findcu.c | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8b00970..8d27b8d 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
2014-12-11 Mark Wielaard <mjw@redhat.com>
+ * libdw_findcu.c (__libdw_intern_next_unit): Sanity check offset.
+
+2014-12-11 Mark Wielaard <mjw@redhat.com>
+
* dwarf_child.c (__libdw_find_attr): Call __libdw_form_val_len with
die->cu->endp, not the abbrev endp.
* dwarf_getattrs.c (dwarf_getattrs): Likewise.
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index 3c9633e..c783ff8 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -94,6 +94,12 @@ __libdw_intern_next_unit (dbg, debug_types)
return NULL;
}
+ /* Invalid or truncated debug section data? */
+ Elf_Data *data = dbg->sectiondata[debug_types
+ ? IDX_debug_types : IDX_debug_info];
+ if (unlikely (*offsetp > data->d_size))
+ *offsetp = data->d_size;
+
/* Create an entry for this CU. */
struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
--
2.1.0