Make sure we're dealing with a static binary. Otherwise we could crash if
the user mistakenly tries to boot a KASLR kernel with 'boot' instead of 'pkboot'. Now we fail cleanly. Reported by cryo@.
This commit is contained in:
parent
ad122cfd79
commit
ed6d73e306
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */
|
||||
/* $NetBSD: loadfile_elf32.c,v 1.56 2019/10/17 14:00:28 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
|
||||
@ -699,6 +699,11 @@ ELFNAMEEND(loadfile_static)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
|
||||
|
||||
internalize_ehdr(elf->e_ident[EI_DATA], elf);
|
||||
|
||||
if (elf->e_type != ET_EXEC) {
|
||||
errno = EINVAL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sz = elf->e_phnum * sizeof(Elf_Phdr);
|
||||
phdr = ALLOC(sz);
|
||||
ret = ELFNAMEEND(readfile_local)(fd, elf->e_phoff, phdr, sz);
|
||||
|
Loading…
Reference in New Issue
Block a user