Module Name: src Committed By: kamil Date: Fri May 31 23:19:38 UTC 2019
Modified Files: src/sys/kern: kern_proc.c Log Message: Use proper copylen for copyout in fill_cwd() To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_proc.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_proc.c diff -u src/sys/kern/kern_proc.c:1.229 src/sys/kern/kern_proc.c:1.230 --- src/sys/kern/kern_proc.c:1.229 Fri May 31 23:01:39 2019 +++ src/sys/kern/kern_proc.c Fri May 31 23:19:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.229 2019/05/31 23:01:39 kamil Exp $ */ +/* $NetBSD: kern_proc.c,v 1.230 2019/05/31 23:19:38 kamil Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.229 2019/05/31 23:01:39 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.230 2019/05/31 23:19:38 kamil Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -2624,7 +2624,8 @@ fill_cwd(struct lwp *l, pid_t pid, void lenused = bend - bp; if (oldp != NULL) { - error = sysctl_copyout(l, bp, oldp, lenused); + size_t copylen = uimin(lenused, *oldlenp); + error = sysctl_copyout(l, bp, oldp, copylen); if (error == 0 && *oldlenp < lenused) error = ENOSPC; }