diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-10-18 09:31:06 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-10-18 09:31:06 +0000 |
commit | 905a8d25e8ffcc7ee48caf54652a2ceb4241792a (patch) | |
tree | 210d8bd2e6e1fe2b2fe818982c6292ee4cd99a95 /sbin/sysctl/sysctl.c | |
parent | db3292d79630719a025732ed2b390a287ebba07f (diff) |
Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@
Diffstat (limited to 'sbin/sysctl/sysctl.c')
-rw-r--r-- | sbin/sysctl/sysctl.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 9ee8a70751f..1b981f0d067 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.222 2016/10/09 06:20:25 otto Exp $ */ +/* $OpenBSD: sysctl.c,v 1.223 2016/10/18 09:31:05 otto Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -1837,17 +1837,14 @@ sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep) if (lp.list == NULL) return (-1); lp.size = stor + 2; - for (i = 1; - (lp.list[i].ctl_name = strsep(&buf, ",")) != NULL; - i++) { - if (lp.list[i].ctl_name[0] == '\0') { + for (i = 1; (ptr = strsep(&buf, ",")) != NULL; i++) { + if (ptr[0] == '\0') { i--; continue; } + lp.list[i].ctl_name = ptr; lp.list[i].ctl_type = CTLTYPE_STRUCT; } - lp.list[i].ctl_name = buf; - lp.list[i].ctl_type = CTLTYPE_STRUCT; listall(string, &lp); free(lp.list); return (-1); |