Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Reorder code to avoid using an uninitialized variab...



details:   https://anonhg.NetBSD.org/src/rev/70d93365f0e7
branches:  trunk
changeset: 326646:70d93365f0e7
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Feb 09 14:51:13 2014 +0000

description:
Reorder code to avoid using an uninitialized variable: if
sysctl_copyin fails, 'tmp' is not initialized. This bug is
harmless since only the return value will be different;
it does not expose kernel memory unless diagnostic is enabled.

ok agc@ martin@

diffstat:

 sys/kern/kern_sysctl.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (35 lines):

diff -r 6c8bfa71a132 -r 70d93365f0e7 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Sun Feb 09 14:44:42 2014 +0000
+++ b/sys/kern/kern_sysctl.c    Sun Feb 09 14:51:13 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sysctl.c,v 1.244 2014/01/17 02:12:48 pooka Exp $  */
+/*     $NetBSD: kern_sysctl.c,v 1.245 2014/02/09 14:51:13 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.244 2014/01/17 02:12:48 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.245 2014/02/09 14:51:13 maxv Exp $");
 
 #include "opt_defcorename.h"
 #include "ksyms.h"
@@ -1549,14 +1549,12 @@
                        return EINVAL;
                }
                error = sysctl_copyin(l, newp, &tmp, sz);
+               if (error)
+                       break;
                if (tmp != true && tmp != false) {
                        DPRINTF(("%s: tmp %d\n", __func__, tmp));
                        return EINVAL;
                }
-               if (error) {
-                       DPRINTF(("%s: copyin %d\n", __func__, error));
-                       break;
-               }
                *(bool *)d = tmp;
                break;
        }



Home | Main Index | Thread Index | Old Index