Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fail if getcwd fails. Pointed out by maxv@



details:   https://anonhg.NetBSD.org/src/rev/a852df500943
branches:  trunk
changeset: 452275:a852df500943
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jun 25 21:32:58 2019 +0000

description:
Fail if getcwd fails. Pointed out by maxv@

diffstat:

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

diffs (48 lines):

diff -r 3992c4d50b6a -r a852df500943 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Tue Jun 25 21:26:04 2019 +0000
+++ b/sys/kern/kern_exec.c      Tue Jun 25 21:32:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.471 2019/06/25 19:47:35 wiz Exp $      */
+/*     $NetBSD: kern_exec.c,v 1.472 2019/06/25 21:32:58 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.471 2019/06/25 19:47:35 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.472 2019/06/25 21:32:58 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -630,9 +630,8 @@
                error = copyinstr(upath, path, MAXPATHLEN, &len);
        }
        if (error) {
-               PNBUF_PUT(path);
                DPRINTF(("%s: copyin path @%p %d\n", __func__, upath, error));
-               return error;
+               goto err;
        }
 
        if (path[0] == '/') {
@@ -657,7 +656,7 @@
        if (error) {
                DPRINTF(("%s: getcwd_common path %s %d\n", __func__, path,
                    error));
-               goto out;
+               goto err;
        }
        tlen = path + MAXPATHLEN - bp;
 
@@ -668,6 +667,9 @@
 out:
        *pbp = pathbuf_assimilate(path);
        return 0;
+err:
+       PNBUF_PUT(path);
+       return error;
 }
 
 vaddr_t



Home | Main Index | Thread Index | Old Index