diff options
author | 2012-06-19 18:43:27 +0000 | |
---|---|---|
committer | 2012-06-19 18:43:27 +0000 | |
commit | c943a8e57602229d86100be2fd799f1b762e6b47 (patch) | |
tree | 7821032ae039c14c5c5e66905c7a5896b35ffd66 | |
parent | sshd_config: extend Match to allow AcceptEnv and {Allow,Deny}{Users,Groups} (diff) | |
download | wireguard-openbsd-c943a8e57602229d86100be2fd799f1b762e6b47.tar.xz wireguard-openbsd-c943a8e57602229d86100be2fd799f1b762e6b47.zip |
Use calloc() instead of malloc() for allocating the disk stats.
Requested by deraadt.
-rw-r--r-- | usr.sbin/snmpd/mib.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index 57d61b5ddcb..f01b3f2af28 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.54 2012/06/14 17:31:32 matthew Exp $ */ +/* $OpenBSD: mib.c,v 1.55 2012/06/19 18:43:27 matthew Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -3406,10 +3406,11 @@ mib_diskio(struct oid *oid, struct ber_oid *o, struct ber_element **elm) o->bo_id[OIDIDX_diskIOEntry] = idx; ber = ber_add_oid(ber, o); - len = diskcount * sizeof(*stats); - stats = malloc(len); + stats = calloc(diskcount, sizeof(*stats)); if (stats == NULL) return (-1); + /* We know len won't overflow, otherwise calloc() would have failed. */ + len = diskcount * sizeof(*stats); mib[1] = HW_DISKSTATS; if (sysctl(mib, sizeofa(mib), stats, &len, NULL, 0) == -1) { free(stats); |