Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Use proper copylen for copyout in fill_cwd()



details:   https://anonhg.NetBSD.org/src/rev/09fd5bf39946
branches:  trunk
changeset: 999414:09fd5bf39946
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri May 31 23:19:38 2019 +0000

description:
Use proper copylen for copyout in fill_cwd()

diffstat:

 sys/kern/kern_proc.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 70d4b0063712 -r 09fd5bf39946 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c      Fri May 31 23:01:39 2019 +0000
+++ b/sys/kern/kern_proc.c      Fri May 31 23:19:38 2019 +0000
@@ -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 @@
        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;
        }



Home | Main Index | Thread Index | Old Index