commit:     0b5d5d35b7b745dfff588579cda1245c5a4d19cb
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 25 05:50:23 2024 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Jan 25 05:50:23 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=0b5d5d35

paxelf: reject ELFs with incomplete Ehdr structures

There's nothing useful we can parse out of these, so skip them.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 paxelf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/paxelf.c b/paxelf.c
index 9a34ea4..599d54f 100644
--- a/paxelf.c
+++ b/paxelf.c
@@ -620,6 +620,11 @@ free_elf_and_return:
                char invalid; \
                const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
                Elf ## B ## _Off size; \
+               /* Need enough bytes for all of ehdr. */ \
+               if (elf->len < (off_t)sizeof(*ehdr)) { \
+                       warn("%s: Incomplete ELF header", filename); \
+                       goto free_elf_and_return; \
+               } \
                /* verify program header */ \
                invalid = 0; \
                if (EGET(ehdr->e_phnum) <= 0) \

Reply via email to