Mercurial > illumos > illumos-gate
changeset 10429:905b255607c2
6873852 nfsstat dies due to uninitialized ksum_kstat
author | Marcel Telka <Marcel.Telka@Sun.COM> |
---|---|
date | Tue, 01 Sep 2009 06:38:59 +0200 |
parents | 3386c7875cc2 |
children | e48d1848c913 |
files | usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c Mon Aug 31 19:10:54 2009 -0700 +++ b/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c Tue Sep 01 06:38:59 2009 +0200 @@ -510,8 +510,8 @@ if ((kc = kstat_open()) == NULL) fail(1, "kstat_open(): can't open /dev/kstat"); - /* malloc space for our temporary kstat */ - ksum_kstat = malloc(sizeof (kstat_t)); + /* alloc space for our temporary kstat */ + safe_zalloc((void **)&ksum_kstat, sizeof (kstat_t), 0); rpc_clts_client_kstat = kstat_lookup(kc, "unix", 0, "rpc_clts_client"); rpc_clts_server_kstat = kstat_lookup(kc, "unix", 0, "rpc_clts_server"); rpc_cots_client_kstat = kstat_lookup(kc, "unix", 0, "rpc_cots_client"); @@ -1424,14 +1424,13 @@ } /* - * "Safe" allocators - if we return we're guaranteed - * to have the desired space. We exit via fail - * if we can't get the space. + * "Safe" allocators - if we return we're guaranteed to have the desired space + * allocated and zero-filled. We exit via fail if we can't get the space. */ void safe_zalloc(void **ptr, uint_t size, int free_first) { - if (*ptr == NULL) + if (ptr == NULL) fail(1, "invalid pointer"); if (free_first && *ptr != NULL) free(*ptr);