Skip to content

Commit

Permalink
paxelf: reject ELFs with incomplete Ehdr structures
Browse files Browse the repository at this point in the history
There's nothing useful we can parse out of these, so skip them.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  • Loading branch information
vapier committed Jan 25, 2024
1 parent 0c6f0ca commit 0b5d5d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions paxelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@ elfobj *readelf_buffer(const char *filename, const void *buffer, size_t buffer_l
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) \
Expand Down

0 comments on commit 0b5d5d3

Please sign in to comment.