aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-25 22:57:24 -0500
committerSam James <sam@gentoo.org>2024-08-09 11:06:16 +0100
commit599d8c41b144596764b33d87d09f80948652ed92 (patch)
treecebf4d852336fc1c855cbedb02e22fc192fe41bc
parentdumpelf: check dyn pointer before DT_NULL check too (diff)
downloadpax-utils-599d8c41b144596764b33d87d09f80948652ed92.tar.gz
pax-utils-599d8c41b144596764b33d87d09f80948652ed92.tar.bz2
pax-utils-599d8c41b144596764b33d87d09f80948652ed92.zip
dumpelf: improve note memory check
Make sure the entire structure fits within the bounds of memory, not just the start of it. Bug: https://bugs.gentoo.org/922906 Signed-off-by: Mike Frysinger <vapier@gentoo.org> (cherry picked from commit a5298c41c27a35a5c2dcca0723c808029d241953) Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--dumpelf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dumpelf.c b/dumpelf.c
index 6ce8403..b88be0c 100644
--- a/dumpelf.c
+++ b/dumpelf.c
@@ -232,7 +232,7 @@ static void dump_notes(const elfobj *elf, size_t B, const void *memory, const vo
}
printf("\n\t/%c note section dump:\n", '*');
- for (i = 0; ndata < memory_end && !corrupt; ++i) {
+ for (i = 0; ndata < memory_end - sizeof(*note) && !corrupt; ++i) {
note = ndata;
namesz = EGET(note->n_namesz);
descsz = EGET(note->n_descsz);