From 255d921adcedcece0bcac9b966b28ed85e3c6526 Mon Sep 17 00:00:00 2001 From: Kai Wang Date: Sun, 19 Jan 2014 13:38:40 +0000 Subject: [PATCH] Add a sanity check: The provided offset for the desired location list should not exceed the size of the .debug_loc section. --- contrib/elftoolchain/libdwarf/libdwarf_loclist.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/elftoolchain/libdwarf/libdwarf_loclist.c b/contrib/elftoolchain/libdwarf/libdwarf_loclist.c index 8b599868d00d..8030e9a67852 100644 --- a/contrib/elftoolchain/libdwarf/libdwarf_loclist.c +++ b/contrib/elftoolchain/libdwarf/libdwarf_loclist.c @@ -127,6 +127,11 @@ _dwarf_loclist_add(Dwarf_Debug dbg, Dwarf_CU cu, uint64_t lloff, return (DW_DLE_NO_ENTRY); } + if (lloff >= ds->ds_size) { + DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY); + return (DW_DLE_NO_ENTRY); + } + if ((ll = malloc(sizeof(struct _Dwarf_Loclist))) == NULL) { DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); return (DW_DLE_MEMORY);