public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.
@ 2016-08-12  9:52 Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-08-12  9:52 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 1951 bytes --]

When reading the phdrs from a core file segment fails we would try to read
them from the exec. This fallback path contained a faulty assert that the
requested size of the phdrs was still setup. But the core file reading
callback might have reset the d_size value to zero on error. So explicitly
set the number of bytes we want to read again instead of asserting the size.

https://bugzilla.redhat.com/show_bug.cgi?id=1365812

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 libdwfl/ChangeLog  | 4 ++++
 libdwfl/link_map.c | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index bdfc92f..3332db7 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2016-08-12  Mark Wielaard  <mjw@redhat.com>
+
+	* link_map.c (dwfl_link_map_report): Fix assert, set in.d_size.
+
 2016-04-14  Mark Wielaard  <mjw@redhat.com>
 
 	* dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Free match
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 28d7382..794668f 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -1,5 +1,5 @@
 /* Report modules by examining dynamic linker data structures.
-   Copyright (C) 2008-2015 Red Hat, Inc.
+   Copyright (C) 2008-2016 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -843,7 +843,10 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
 		}
 	      off_t off = ehdr->e_phoff;
 	      assert (in.d_buf == NULL);
-	      assert (in.d_size == phnum * phent);
+	      /* Note this in the !in_ok path.  That means memory_callback
+		 failed.  But the callback might still have reset the d_size
+		 value (to zero).  So explicitly set it here again.  */
+	      in.d_size = phnum * phent;
 	      in.d_buf = malloc (in.d_size);
 	      if (unlikely (in.d_buf == NULL))
 		{
-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.
@ 2016-08-16  8:38 Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-08-16  8:38 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

On Fri, Aug 12, 2016 at 11:52:51AM +0200, Mark Wielaard wrote:
> When reading the phdrs from a core file segment fails we would try to read
> them from the exec. This fallback path contained a faulty assert that the
> requested size of the phdrs was still setup. But the core file reading
> callback might have reset the d_size value to zero on error. So explicitly
> set the number of bytes we want to read again instead of asserting the size.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1365812

I pushed this to master.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-16  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12  9:52 [PATCH] libdwfl: Fix assert and set in.d_size in dwfl_link_map_report Mark Wielaard
2016-08-16  8:38 Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).