Module Name: src Committed By: martin Date: Fri May 16 08:59:24 UTC 2014
Modified Files: src/sbin/sysctl: sysctl.c Log Message: Do not loop over children if a node is not marked as CTLTYPE_NODE. To generate a diff of this commit: cvs rdiff -u -r1.151 -r1.152 src/sbin/sysctl/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/sbin/sysctl/sysctl.c diff -u src/sbin/sysctl/sysctl.c:1.151 src/sbin/sysctl/sysctl.c:1.152 --- src/sbin/sysctl/sysctl.c:1.151 Fri Jan 10 18:37:18 2014 +++ src/sbin/sysctl/sysctl.c Fri May 16 08:59:24 2014 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1993\ #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 @@ getdesc(int *name, u_int namelen, struct 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 @@ getdesc(int *name, u_int namelen, struct * 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)