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]

libdwfl_report_elf error path fixlet


Hi,

Through user error (me) I was reporting the same file through
dwfl_report_offline () which currently SEGFAULTS because
__libdwfl_report_elf doesn't actually return NULL on DWFL_E_OVERLAP and
calls elf_end twice (the caller also calls elf_end on error). This patch
fixes that so that you get a NULL return and DWFL_E_OVERLAP set, giving
the application the opportunity to recover from its own failure.

Cheers,

Mark
>From 2adf8cacc73cf57ff9c7dfb369f9854b06f6b6fb Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Thu, 18 Jun 2009 13:31:56 +0200
Subject: [PATCH] __libdwfl_report_elf: Return NULL on overlap, don't (double) close elf.

---
 libdwfl/ChangeLog         |    4 ++++
 libdwfl/dwfl_report_elf.c |    3 +--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 97e888f..f2348e2 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-18  Mark Wielaard  <mjw@redhat.com>
+
+	* dwfl_report_elf.c (__libdwfl_report_elf): Return NULL on overlap.
+
 2009-06-13  Ulrich Drepper  <drepper@redhat.com>
 
 	* derelocate.c: Don't use deprecated libelf functions.
diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c
index a58d302..52b0c57 100644
--- a/libdwfl/dwfl_report_elf.c
+++ b/libdwfl/dwfl_report_elf.c
@@ -235,11 +235,10 @@ __libdwfl_report_elf (Dwfl *dwfl, const char *name, const char *file_name,
       else if ((fd >= 0 && m->main.fd != fd)
 	       || strcmp (m->main.name, file_name))
 	{
-	  elf_end (elf);
 	overlap:
 	  m->gc = true;
 	  __libdwfl_seterrno (DWFL_E_OVERLAP);
-	  m = NULL;
+	  return NULL;
 	}
 
       /* Preinstall the open ELF handle for the module.  */
-- 
1.6.2.2


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