From: Mark Wielaard Date: Thu, 18 Jun 2015 08:46:20 +0000 (+0200) Subject: libdwfl: Check symbol section exists and has a sane entsize in find_symtab. X-Git-Tag: elfutils-0.163~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=821e15c6ca716b17b3d3b678cfb17d12ef9bcf25;p=thirdparty%2Felfutils.git libdwfl: Check symbol section exists and has a sane entsize in find_symtab. Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index a5253e261..ca987833a 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 908a9eee1..dba9d6649 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;