Module Name:    src
Committed By:   skrll
Date:           Sat Dec 21 17:44:33 UTC 2013

Modified Files:
        src/sys/kern: exec_elf.c

Log Message:
Check interp after reading it. Checking newly allocated memory doesn't
work.

Hi Christos.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/sys/kern/exec_elf.c:1.53
--- src/sys/kern/exec_elf.c:1.52	Sat Dec 21 14:41:02 2013
+++ src/sys/kern/exec_elf.c	Sat Dec 21 17:44:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.52 2013/12/21 14:41:02 christos Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.53 2013/12/21 17:44:33 skrll 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.52 2013/12/21 14:41:02 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.53 2013/12/21 17:44:33 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -709,14 +709,14 @@ exec_elf_makecmds(struct lwp *l, struct 
 				goto bad;
 			}
 			interp = PNBUF_GET();
+			if ((error = exec_read_from(l, epp->ep_vp,
+			    pp->p_offset, interp, pp->p_filesz)) != 0)
+				goto bad;
 			/* Ensure interp is NUL-terminated and of the expected length */
 			if (strnlen(interp, pp->p_filesz) != pp->p_filesz - 1) {
 				error = ENOEXEC;
 				goto bad;
 			}
-			if ((error = exec_read_from(l, epp->ep_vp,
-			    pp->p_offset, interp, pp->p_filesz)) != 0)
-				goto bad;
 			break;
 		}
 	}

Reply via email to