aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-25 00:50:23 -0500
committerMike Frysinger <vapier@gentoo.org>2024-01-25 00:50:23 -0500
commit0b5d5d35b7b745dfff588579cda1245c5a4d19cb (patch)
tree1c119cb7dcca7e04e7bf3dc43bc40cc300a61af6
parentREADME: update macOS name (diff)
downloadpax-utils-0b5d5d35b7b745dfff588579cda1245c5a4d19cb.tar.gz
pax-utils-0b5d5d35b7b745dfff588579cda1245c5a4d19cb.tar.bz2
pax-utils-0b5d5d35b7b745dfff588579cda1245c5a4d19cb.zip
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@gentoo.org>
-rw-r--r--paxelf.c5
1 files changed, 5 insertions, 0 deletions
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) \