Module Name:    src
Committed By:   christos
Date:           Mon Nov 13 22:01:45 UTC 2017

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

Log Message:
grab a copy of the absolute pathbuf, before namei() munges it.


To generate a diff of this commit:
cvs rdiff -u -r1.452 -r1.453 src/sys/kern/kern_exec.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/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.452 src/sys/kern/kern_exec.c:1.453
--- src/sys/kern/kern_exec.c:1.452	Mon Nov 13 15:38:31 2017
+++ src/sys/kern/kern_exec.c	Mon Nov 13 17:01:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.452 2017/11/13 20:38:31 christos Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.453 2017/11/13 22:01:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.452 2017/11/13 20:38:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.453 2017/11/13 22:01:45 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -338,15 +338,17 @@ check_exec(struct lwp *l, struct exec_pa
 	struct nameidata nd;
 	size_t		resid;
 
+#if 1
+	// grab the absolute pathbuf here before namei() trashes it.
+	pathbuf_copystring(pb, epp->ep_resolvedname, PATH_MAX);
+#endif
 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb);
 
 	/* first get the vnode */
 	if ((error = namei(&nd)) != 0)
 		return error;
 	epp->ep_vp = vp = nd.ni_vp;
-#if 1
-	pathbuf_copystring(pb, epp->ep_resolvedname, PATH_MAX);
-#else
+#if 0
 	/*
 	 * XXX: can't use nd.ni_pnbuf, because although pb contains an
 	 * absolute path, nd.ni_pnbuf does not if the path contains symlinks.

Reply via email to