diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-09-02 15:19:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-09-02 15:19:41 +0000 |
commit | 6ebd04219f0d749c87a763e8afb578dfcd5223cc (patch) | |
tree | bb0f29e0a3791fff88551c93f5d4ba7113bdba43 /usr.bin/systat | |
parent | be524287dc216d876f995eddcaf32762c702c6e9 (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.c | 7 |
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(); } |