diff options
author | deraadt <deraadt@openbsd.org> | 2007-09-02 15:19:07 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2007-09-02 15:19:07 +0000 |
commit | 1ed98fdf61d9dd29369f246109081408082ce54d (patch) | |
tree | ad7631e58c83830d1fc51cbadb9a2da53c1abfb7 /usr.sbin/pstat | |
parent | OpenCVS server init-support with OpenCVS and GNU cvs clients. (diff) | |
download | wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.tar.xz wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.zip |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.sbin/pstat')
-rw-r--r-- | usr.sbin/pstat/pstat.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 5fc9deca33d..fb1aefe54d4 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pstat.c,v 1.64 2006/06/04 01:39:32 deraadt Exp $ */ +/* $OpenBSD: pstat.c,v 1.65 2007/09/02 15:19:40 deraadt Exp $ */ /* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */ /*- @@ -40,7 +40,7 @@ static char copyright[] = #if 0 from: static char sccsid[] = "@(#)pstat.c 8.9 (Berkeley) 2/16/94"; #else -static char *rcsid = "$OpenBSD: pstat.c,v 1.64 2006/06/04 01:39:32 deraadt Exp $"; +static char *rcsid = "$OpenBSD: pstat.c,v 1.65 2007/09/02 15:19:40 deraadt Exp $"; #endif #endif /* not lint */ @@ -1015,7 +1015,7 @@ swapmode(void) "Total", hlen, 0, 0, 0, 0.0); return; } - if ((swdev = malloc(nswap * sizeof(*swdev))) == NULL) + if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL) err(1, "malloc"); if (swapctl(SWAP_STATS, swdev, nswap) == -1) err(1, "swapctl"); |