Source-Changes-HG archive

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

[src/trunk]: src/sys/kern grab a copy of the absolute pathbuf, before namei()...



details:   https://anonhg.NetBSD.org/src/rev/726de0900e80
branches:  trunk
changeset: 827826:726de0900e80
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Nov 13 22:01:45 2017 +0000

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

diffstat:

 sys/kern/kern_exec.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (39 lines):

diff -r 33a5578c6ed5 -r 726de0900e80 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Mon Nov 13 21:33:42 2017 +0000
+++ b/sys/kern/kern_exec.c      Mon Nov 13 22:01:45 2017 +0000
@@ -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 @@
        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.



Home | Main Index | Thread Index | Old Index