Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Make sure we're dealing with a static binary. ...
details: https://anonhg.NetBSD.org/src/rev/0750ee1de4a0
branches: trunk
changeset: 464696:0750ee1de4a0
user: maxv <maxv%NetBSD.org@localhost>
date: Thu Oct 17 14:00:28 2019 +0000
description:
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@.
diffstat:
sys/lib/libsa/loadfile_elf32.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diffs (21 lines):
diff -r 9ac10ca1be40 -r 0750ee1de4a0 sys/lib/libsa/loadfile_elf32.c
--- a/sys/lib/libsa/loadfile_elf32.c Thu Oct 17 09:38:07 2019 +0000
+++ b/sys/lib/libsa/loadfile_elf32.c Thu Oct 17 14:00:28 2019 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index