From 821e15c6ca716b17b3d3b678cfb17d12ef9bcf25 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 Jun 2015 10:46:20 +0200 Subject: [PATCH] libdwfl: Check symbol section exists and has a sane entsize in find_symtab. Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 5 +++++ libdwfl/dwfl_module_getdwarf.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index a5253e2..ca98783 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2015-06-18 Mark Wielaard + + * dwfl_module_getdwarf.c (find_symtab): Check shdr is not NULL and + sh_entsize is not zero. + 2015-06-06 Mark Wielaard * find-debuginfo.c (find_debuginfo_in_path): Always free localpath, diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index 908a9ee..dba9d66 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -1135,7 +1135,8 @@ find_symtab (Dwfl_Module *mod) // Sanity check number of symbols. GElf_Shdr shdr_mem, *shdr = gelf_getshdr (symscn, &shdr_mem); - if (mod->syments > mod->symdata->d_size / shdr->sh_entsize + if (shdr == NULL || shdr->sh_entsize == 0 + || mod->syments > mod->symdata->d_size / shdr->sh_entsize || (size_t) mod->first_global > mod->syments) goto elferr; -- 2.7.4