Source-Changes-HG archive

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

[src/trunk]: src/sys/kern - add missing error check



details:   https://anonhg.NetBSD.org/src/rev/121a4b13eed9
branches:  trunk
changeset: 965384:121a4b13eed9
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 14 21:23:34 2019 +0000

description:
- add missing error check
- use '\0' for char const

diffstat:

 sys/kern/vfs_getcwd.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 40f636d72d21 -r 121a4b13eed9 sys/kern/vfs_getcwd.c
--- a/sys/kern/vfs_getcwd.c     Sat Sep 14 21:09:00 2019 +0000
+++ b/sys/kern/vfs_getcwd.c     Sat Sep 14 21:23:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_getcwd.c,v 1.52 2017/07/28 15:37:23 riastradh Exp $ */
+/* $NetBSD: vfs_getcwd.c,v 1.53 2019/09/14 21:23:34 christos Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.52 2017/07/28 15:37:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.53 2019/09/14 21:23:34 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -570,6 +570,8 @@
        error = getcwd_common(dvp, NULL, &bp, path, len / 2,
            GETCWD_CHECK_ACCESS, curl);
        vrele(dvp);
+       if (error != 0)
+               return error;
 
        /*
         * Strip off emulation path for emulated processes looking at
@@ -585,7 +587,7 @@
        lenused = bend - bp;
 
        memcpy(path, bp, lenused);
-       path[lenused] = 0;
+       path[lenused] = '\0';
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index