[PATCH] libdwfl: Check symbol section exists and has a sane entsize in find_symtab.
Mark Wielaard
mjw at redhat.com
Thu Jun 18 08:48:31 UTC 2015
Signed-off-by: Mark Wielaard <mjw at redhat.com>
---
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 <mjw at redhat.com>
+
+ * dwfl_module_getdwarf.c (find_symtab): Check shdr is not NULL and
+ sh_entsize is not zero.
+
2015-06-06 Mark Wielaard <mjw at redhat.com>
* 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;
--
1.8.3.1
More information about the elfutils-devel
mailing list