Module Name: src Committed By: martin Date: Mon Aug 26 12:24:10 UTC 2013
Modified Files: src/sys/kern: exec_elf.c Log Message: Fix a comment and a few minor optimizations: * elf_check_header() already ensures eh.e_phnum > MAXPHNUM, so do not test it again at the call site * is_dyn == true implies a successfull call to elf_check_header(eh, ET_DYN), so no need to call elf_check_header(eh, ET_EXEC) >From Maxime Villard. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/kern/exec_elf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/exec_elf.c diff -u src/sys/kern/exec_elf.c:1.45 src/sys/kern/exec_elf.c:1.46 --- src/sys/kern/exec_elf.c:1.45 Tue Apr 9 07:39:01 2013 +++ src/sys/kern/exec_elf.c Mon Aug 26 12:24:10 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_elf.c,v 1.45 2013/04/09 07:39:01 skrll Exp $ */ +/* $NetBSD: exec_elf.c,v 1.46 2013/08/26 12:24:10 martin Exp $ */ /*- * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.45 2013/04/09 07:39:01 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.46 2013/08/26 12:24:10 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_pax.h" @@ -280,7 +280,7 @@ elf_copyargs(struct lwp *l, struct exec_ /* * elf_check_header(): * - * Check header for validity; return 0 of ok ENOEXEC if error + * Check header for validity; return 0 if ok, ENOEXEC if error */ int elf_check_header(Elf_Ehdr *eh, int type) @@ -493,7 +493,7 @@ elf_load_file(struct lwp *l, struct exec if ((error = elf_check_header(&eh, ET_DYN)) != 0) goto bad; - if (eh.e_phnum > MAXPHNUM || eh.e_phnum == 0) { + if (eh.e_phnum == 0) { error = ENOEXEC; goto bad; } @@ -676,10 +676,10 @@ exec_elf_makecmds(struct lwp *l, struct * XXX allow for executing shared objects. It seems silly * but other ELF-based systems allow it as well. */ - if (elf_check_header(eh, ET_EXEC) != 0 && !is_dyn) + if (!is_dyn && elf_check_header(eh, ET_EXEC) != 0) return ENOEXEC; - if (eh->e_phnum > MAXPHNUM || eh->e_phnum == 0) + if (eh->e_phnum == 0) return ENOEXEC; error = vn_marktext(epp->ep_vp);