summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
commit6ebd04219f0d749c87a763e8afb578dfcd5223cc (patch)
treebb0f29e0a3791fff88551c93f5d4ba7113bdba43 /usr.bin/systat
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/pigs.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
index 2f2640e8112..46b36311559 100644
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pigs.c,v 1.20 2007/02/25 18:21:24 deraadt Exp $ */
+/* $OpenBSD: pigs.c,v 1.21 2007/09/02 15:19:35 deraadt Exp $ */
/* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
#endif
-static char rcsid[] = "$OpenBSD: pigs.c,v 1.20 2007/02/25 18:21:24 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pigs.c,v 1.21 2007/09/02 15:19:35 deraadt Exp $";
#endif /* not lint */
/*
@@ -181,8 +181,7 @@ fetchpigs(void)
}
if (nproc > lastnproc) {
free(pt);
- if ((pt =
- malloc((nproc + 1) * sizeof(struct p_times))) == NULL) {
+ if ((pt = calloc(nproc + 1, sizeof(struct p_times))) == NULL) {
error("Out of memory");
die();
}