diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-05-14 07:01:38 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-05-14 07:01:38 +0000 |
commit | 638f2cb09044312f769da2102167e7ef1d1e39f8 (patch) | |
tree | f6b88b7d6fcb6f3a89ee0dd6ee7e9cac140cf55a /sys | |
parent | 2646d1dcd79bdb6ce8d837bf708486906ec0a755 (diff) |
Be more paranoid about zapping trailing comma.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_malloc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index a479b236d9e..974da0ac31c 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.29 2001/05/14 06:56:30 angelos Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.30 2001/05/14 07:01:37 angelos Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -501,7 +501,9 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen) for (siz = 0, i = MINBUCKET; i < MINBUCKET + 16; i++) siz += sprintf(buckstring + siz, "%d,", (u_int)(1<<i)); - buckstring[siz - 1] = '\0'; /* Remove trailing comma */ + /* Remove trailing comma */ + if (siz) + buckstring[siz - 1] = '\0'; } return (sysctl_rdstring(oldp, oldlenp, newp, buckstring)); @@ -536,7 +538,10 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen) for (siz = 0, i = 0; i < M_LAST; i++) siz += sprintf(memall + siz, "%s,", memname[i] ? memname[i] : ""); - memall[siz - 1] = '\0'; /* Remove trailing comma */ + + /* Remove trailing comma */ + if (siz) + memall[siz - 1] = '\0'; /* Now, convert all spaces to underscores */ for (i = 0; i < totlen; i++) |