From e394f9099e3fd4d7d5eef56cf1a3219696712212 Mon Sep 17 00:00:00 2001 From: cheloha Date: Sat, 14 Jan 2023 01:04:55 +0000 Subject: [PATCH] sysctl(2): KERN_CPUSTATS: zero struct cpustats before copyout --- sys/kern/kern_sysctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ff42ebb5129..7bd657691c8 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.408 2022/11/07 14:25:44 robert Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.409 2023/01/14 01:04:55 cheloha Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -2510,6 +2510,7 @@ sysctl_cpustats(int *name, u_int namelen, void *oldp, size_t *oldlenp, if (!found) return (ENOENT); + memset(&cs, 0, sizeof cs); memcpy(&cs.cs_time, &ci->ci_schedstate.spc_cp_time, sizeof(cs.cs_time)); cs.cs_flags = 0; if (cpu_is_online(ci)) -- 2.20.1