Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Fix a comment and a few minor optimizations:



details:   https://anonhg.NetBSD.org/src/rev/e9c4432bf8f2
branches:  trunk
changeset: 789605:e9c4432bf8f2
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Aug 26 12:24:10 2013 +0000

description:
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.

diffstat:

 sys/kern/exec_elf.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (49 lines):

diff -r da5ed902a7bb -r e9c4432bf8f2 sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Mon Aug 26 07:14:59 2013 +0000
+++ b/sys/kern/exec_elf.c       Mon Aug 26 12:24:10 2013 +0000
@@ -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_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 @@
        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 @@
         * 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);



Home | Main Index | Thread Index | Old Index