-/* $OpenBSD: exec_elf.c,v 1.113 2015/03/30 21:08:38 miod Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.114 2015/04/26 05:30:42 guenther Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
for (i = 0; i < eh.e_phnum; i++) {
if (ph[i].p_type == PT_LOAD) {
+ if (ph[i].p_filesz > ph[i].p_memsz)
+ goto bad1;
loadmap[idx].vaddr = trunc_page(ph[i].p_vaddr);
loadmap[idx].memsz = round_page (ph[i].p_vaddr +
ph[i].p_memsz - loadmap[idx].vaddr);
goto bad;
}
} else if (pp->p_type == PT_LOAD) {
+ if (pp->p_filesz > pp->p_memsz) {
+ error = EINVAL;
+ goto bad;
+ }
if (base_ph == NULL)
base_ph = pp;
} else if (pp->p_type == PT_PHDR) {