diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-05-30 13:10:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-05-30 13:10:24 +0000 |
commit | c2ceb9cd378460ed13abb8b999d95d4c13c81f0e (patch) | |
tree | a72c294f36c59e381f05623c8e3ee2239432f642 /sys/kern/vfs_getcwd.c | |
parent | 3b2fadc678a0f27e85c958e871a3ff58a3e9bea5 (diff) |
use copyoutstr, instead of fragile range math; ok beck
Diffstat (limited to 'sys/kern/vfs_getcwd.c')
-rw-r--r-- | sys/kern/vfs_getcwd.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/vfs_getcwd.c b/sys/kern/vfs_getcwd.c index 035d500cd5c..9b9ba820731 100644 --- a/sys/kern/vfs_getcwd.c +++ b/sys/kern/vfs_getcwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_getcwd.c,v 1.33 2019/05/29 15:22:04 deraadt Exp $ */ +/* $OpenBSD: vfs_getcwd.c,v 1.34 2019/05/30 13:10:23 deraadt Exp $ */ /* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */ /* @@ -39,6 +39,7 @@ #include <sys/lock.h> #include <sys/vnode.h> #include <sys/mount.h> +#include <sys/ktrace.h> #include <sys/proc.h> #include <sys/uio.h> #include <sys/malloc.h> @@ -394,8 +395,8 @@ int sys___getcwd(struct proc *p, void *v, register_t *retval) { struct sys___getcwd_args *uap = v; - int error, lenused, len = SCARG(uap, len); - char *path, *bp, *bend; + int error, len = SCARG(uap, len); + char *path, *bp; if (len > MAXPATHLEN * 4) len = MAXPATHLEN * 4; @@ -405,7 +406,6 @@ sys___getcwd(struct proc *p, void *v, register_t *retval) path = malloc(len, M_TEMP, M_WAITOK); bp = &path[len]; - bend = bp; *(--bp) = '\0'; /* @@ -419,10 +419,8 @@ sys___getcwd(struct proc *p, void *v, register_t *retval) if (error) goto out; - lenused = bend - bp; - /* Put the result into user buffer */ - error = copyout(bp, SCARG(uap, buf), lenused); + error = copyoutstr(bp, SCARG(uap, buf), MAXPATHLEN, NULL); out: free(path, M_TEMP, len); |