summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-19 20:23:30 +0100
committerMark Wielaard <mark@klomp.org>2021-12-19 20:23:30 +0100
commitfece8e1469d22abe524f15805527ea0173e52f04 (patch)
tree77b5aa6b8f4916ac414957c28df577d2c56cb39b
parentlibelf: Only set shdr state when there is at least one shdr (diff)
downloadelfutils-fece8e1469d22abe524f15805527ea0173e52f04.tar.gz
elfutils-fece8e1469d22abe524f15805527ea0173e52f04.tar.bz2
elfutils-fece8e1469d22abe524f15805527ea0173e52f04.tar.xz
libdwfl: Make sure that ph_buffer_size has room for at least one phdr
dwfl_segment_report_module might otherwise try to handle half a phdr taking the other half from after the buffer. Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d00ce702..38e2bdaa 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,10 @@
12021-12-08 Mark Wielaard <mark@klomp.org> 12021-12-08 Mark Wielaard <mark@klomp.org>
2 2
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Make sure
4 that ph_buffer_size has room for at least one phdr.
5
62021-12-08 Mark Wielaard <mark@klomp.org>
7
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Make 8 * dwfl_segment_report_module.c (dwfl_segment_report_module): Make
4 sure the note len increases each iteration. 9 sure the note len increases each iteration.
5 10
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 89e05103..840d6f44 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -426,7 +426,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
426 buffer, otherwise it will be the size of the new buffer that 426 buffer, otherwise it will be the size of the new buffer that
427 could be read. */ 427 could be read. */
428 if (ph_buffer_size != 0) 428 if (ph_buffer_size != 0)
429 xlatefrom.d_size = ph_buffer_size; 429 {
430 phnum = ph_buffer_size / phentsize;
431 if (phnum == 0)
432 goto out;
433 xlatefrom.d_size = ph_buffer_size;
434 }
430 435
431 xlatefrom.d_buf = ph_buffer; 436 xlatefrom.d_buf = ph_buffer;
432 437