This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] libdwfl: Check symbol section exists and has a sane entsize in find_symtab.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 18 Jun 2015 10:48:31 +0200
- Subject: [PATCH] libdwfl: Check symbol section exists and has a sane entsize in find_symtab.
Signed-off-by: Mark Wielaard <mjw@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@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@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