diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -1276,6 +1276,9 @@ * Try and load the symbol table if it's present. (you can * strip it!) */ + if (hdr->e_shnum != 0 && hdr->e_shentsize > SIZE_MAX / hdr->e_shnum) { + return (ENOEXEC); + } nbytes = hdr->e_shnum * hdr->e_shentsize; if (nbytes == 0 || hdr->e_shoff == 0) goto nosyms;