Source-Changes-HG archive

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

[src/trunk]: src/sbin/sysctl Do not loop over children if a node is not marke...



details:   https://anonhg.NetBSD.org/src/rev/ec11ec7ddb29
branches:  trunk
changeset: 796005:ec11ec7ddb29
user:      martin <martin%NetBSD.org@localhost>
date:      Fri May 16 08:59:24 2014 +0000

description:
Do not loop over children if a node is not marked as CTLTYPE_NODE.

diffstat:

 sbin/sysctl/sysctl.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 3abfbbc43241 -r ec11ec7ddb29 sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c      Fri May 16 08:29:18 2014 +0000
+++ b/sbin/sysctl/sysctl.c      Fri May 16 08:59:24 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl.c,v 1.151 2014/01/10 18:37:18 christos Exp $ */
+/*     $NetBSD: sysctl.c,v 1.152 2014/05/16 08:59:24 martin Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)sysctl.c   8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.151 2014/01/10 18:37:18 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.152 2014/05/16 08:59:24 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -1616,7 +1616,7 @@
        struct sysctlnode *node = pnode->sysctl_child;
        struct sysctldesc *d, *p, *plim;
        char *desc;
-       size_t i, sz;
+       size_t i, sz, child_cnt;
        int rc;
 
        sz = 128 * pnode->sysctl_clen;
@@ -1647,7 +1647,9 @@
         * suffice for now
         */
        plim = /*LINTED ptr cast*/(struct sysctldesc *)((char*)d + sz);
-       for (i = 0; i < pnode->sysctl_clen; i++) {
+       child_cnt = (pnode->sysctl_flags & CTLTYPE_NODE) ? pnode->sysctl_clen
+           : 0;
+       for (i = 0; i < child_cnt; i++) {
                node = &pnode->sysctl_child[i];
                for (p = d; p < plim; p = NEXT_DESCR(p))
                        if (node->sysctl_num == p->descr_num)



Home | Main Index | Thread Index | Old Index