+2021-12-08 Mark Wielaard <mark@klomp.org>
+
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): Don't
+ read beyond of (actual) end of (memory) file.
+
2021-11-18 Matthias Maennich <maennich@google.com>
* linux-kernel-modules.c (dwfl_linux_kernel_report_modules):
GElf_Off offset = is32 ? p32[i].p_offset : p64[i].p_offset;
GElf_Xword filesz = is32 ? p32[i].p_filesz : p64[i].p_filesz;
+ /* Don't try to read beyond the actual end of file. */
+ if (offset >= file_trimmed_end)
+ continue;
+
void *into = contents + offset;
- size_t read_size = filesz;
+ size_t read_size = MIN (filesz, file_trimmed_end - offset);
(*memory_callback) (dwfl, addr_segndx (dwfl, segment,
vaddr + bias, false),
&into, &read_size, vaddr + bias, read_size,