Trying to read non-existing bits sometimes works and normally a sanity check will fail. But it could also lead to an unexpected crash much later when trying to use the non-existing data.
Signed-off-by: Mark Wielaard <[email protected]> --- libdw/ChangeLog | 4 ++++ libdw/dwarf_getcfi_elf.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 59b6c63..7e39a2d 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2013-07-02 Mark Wielaard <[email protected]> + + * dwarf_getcfi_elf.c (getcfi_shdr): Check sh_type == SHT_PROGBITS. + 2013-05-03 Mark Wielaard <[email protected]> * dwarf_getsrclines.c (dwarf_getsrclines): Only set end_sequence diff --git a/libdw/dwarf_getcfi_elf.c b/libdw/dwarf_getcfi_elf.c index ba00e05..a423ef3 100644 --- a/libdw/dwarf_getcfi_elf.c +++ b/libdw/dwarf_getcfi_elf.c @@ -280,8 +280,13 @@ getcfi_shdr (Elf *elf, const GElf_Ehdr *ehdr) hdr_vaddr = shdr->sh_addr; } else if (!strcmp (name, ".eh_frame")) - return getcfi_scn_eh_frame (elf, ehdr, scn, shdr, - hdr_scn, hdr_vaddr); + { + if (shdr->sh_type == SHT_PROGBITS) + return getcfi_scn_eh_frame (elf, ehdr, scn, shdr, + hdr_scn, hdr_vaddr); + else + return NULL; + } } } -- 1.7.1 _______________________________________________ elfutils-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel
