This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in dwfl_module_relocations


Hi,

When you call dwfl_module_relocations() on a mod that isn't ET_REL, then
it can potentially return the wrong answer because it checks and returns
mod->reloc_info->count. Which for ET_EXEC and ET_DYN can be setup
because someone called dwfl_module_address_section(), but doesn't
correspond to the actual relocation count in that case.

Does the following fix look sane?

2011-10-19  Mark Wielaard  <mjw@redhat.com>

       * derelocate.c (dwfl_module_relocations): Only check
       mod->reloc_info->count for ET_REL.

Thanks,

Mark
diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c
index ba6d9db..6169ae7 100644
--- a/libdwfl/derelocate.c
+++ b/libdwfl/derelocate.c
@@ -227,12 +227,11 @@ dwfl_module_relocations (Dwfl_Module *mod)
   if (mod == NULL)
     return -1;
 
-  if (mod->reloc_info != NULL)
-    return mod->reloc_info->count;
-
   switch (mod->e_type)
     {
     case ET_REL:
+      if (mod->reloc_info != NULL)
+	return mod->reloc_info->count;
       return cache_sections (mod);
 
     case ET_DYN:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]