diff options
author | 2024-01-25 00:50:23 -0500 | |
---|---|---|
committer | 2024-01-25 00:50:23 -0500 | |
commit | 0b5d5d35b7b745dfff588579cda1245c5a4d19cb (patch) | |
tree | 1c119cb7dcca7e04e7bf3dc43bc40cc300a61af6 | |
parent | README: update macOS name (diff) | |
download | pax-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.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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) \ |