Module Name:    src
Committed By:   maxv
Date:           Wed Jul  3 17:31:32 UTC 2019

Modified Files:
        src/sys/kern: kern_sysctl.c

Log Message:
Invert two conditions, to fix uninitialized memory access. If the node is
an immediate, then the 64 bits of nnode.sysctl_data may not all be
initialized, since this is an union.

Obviously, this is harmless; but still a bug, so fix it.


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/kern/kern_sysctl.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_sysctl.c
diff -u src/sys/kern/kern_sysctl.c:1.263 src/sys/kern/kern_sysctl.c:1.264
--- src/sys/kern/kern_sysctl.c:1.263	Mon Jan 28 15:56:12 2019
+++ src/sys/kern/kern_sysctl.c	Wed Jul  3 17:31:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sysctl.c,v 1.263 2019/01/28 15:56:12 christos Exp $	*/
+/*	$NetBSD: kern_sysctl.c,v 1.264 2019/07/03 17:31:32 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.263 2019/01/28 15:56:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.264 2019/07/03 17:31:32 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_defcorename.h"
@@ -1077,8 +1077,8 @@ sysctl_create(SYSCTLFN_ARGS)
 	 */
 	if (l != NULL || nnode.sysctl_func == NULL) {
 		if (type != CTLTYPE_NODE &&
-		    nnode.sysctl_data == NULL &&
 		    !(flags & CTLFLAG_IMMEDIATE) &&
+		    nnode.sysctl_data == NULL &&
 		    own == NULL)
 			return (EINVAL);
 	}

Reply via email to