summaryrefslogtreecommitdiffstats
path: root/libdw/dwarf_getmacros.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2014-12-04 21:43:44 +0100
committerMark Wielaard <[email protected]>2014-12-11 15:10:14 +0100
commitcb73b5a015606a02f952f7eddaba15327f6191fa (patch)
tree217bc940ebda5bcf26c4be3de047a1fbd5c3359c /libdw/dwarf_getmacros.c
parentedb079a596b25379828836e501d003f20afdb879 (diff)
libdw: Add overflow checking to __libdw_form_val_len.
Pass endp as argument to __libdw_form_val_len and check we don't read beyond the end of expected data and don't return lengths that would overflow. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/dwarf_getmacros.c')
-rw-r--r--libdw/dwarf_getmacros.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index bd64d60f..737dc5d1 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -367,8 +367,12 @@ read_macros (Dwarf *dbg, int sec_index,
attributes[i].valp = (void *) readp;
attributes[i].cu = &fake_cu;
- readp += __libdw_form_val_len (dbg, &fake_cu,
- proto->forms[i], readp);
+ size_t len = __libdw_form_val_len (dbg, &fake_cu,
+ proto->forms[i], readp, endp);
+ if (len == (size_t) -1)
+ return -1;
+
+ readp += len;
}
Dwarf_Macro macro = {