]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Sanity check partial core file phdrs data read.
authorMark Wielaard <mark@klomp.org>
Wed, 27 Mar 2019 21:32:21 +0000 (22:32 +0100)
committerMark Wielaard <mark@klomp.org>
Wed, 27 Mar 2019 21:39:39 +0000 (22:39 +0100)
When reading the phdrs data from the core file check if we got everything,
or just part of the data.

https://sourceware.org/bugzilla/show_bug.cgi?id=24387

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/ChangeLog
libdwfl/dwfl_segment_report_module.c

index 95dc426b64ef147c0679d74965bdafa698052872..1da888f6f9383b8071d64802d0b4cdd33a7f6e8b 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-27  Mark Wielaard  <mark@klomp.org>
+
+       * dwfl_segment_report_module.c (dwfl_segment_report_module): Check
+       ph_buffer_size vs xlatefrom.d_size after read_portion call.
+
 2019-02-24  Mark Wielaard  <mark@klomp.org>
 
        * linux-kernel-modules.c (intuit_kernel_bounds): Init *notes before
index f6ad39b3e442784a3bd1fd5521a5565f30ac26e5..76ba150685c751684e110640aed3ec5f147a98ba 100644 (file)
@@ -412,6 +412,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
                    start + phoff, xlatefrom.d_size))
     return finish ();
 
+  /* ph_buffer_size will be zero if we got everything from the initial
+     buffer, otherwise it will be the size of the new buffer that
+     could be read.  */
+  if (ph_buffer_size != 0)
+    xlatefrom.d_size = ph_buffer_size;
+
   xlatefrom.d_buf = ph_buffer;
 
   bool class32 = ei_class == ELFCLASS32;