summaryrefslogtreecommitdiff
path: root/usr.bin/rs
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/rs
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/rs')
-rw-r--r--usr.bin/rs/rs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/rs/rs.c b/usr.bin/rs/rs.c
index f3524bc0624..bd0fffc33c1 100644
--- a/usr.bin/rs/rs.c
+++ b/usr.bin/rs/rs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rs.c,v 1.17 2006/04/17 09:45:00 moritz Exp $ */
+/* $OpenBSD: rs.c,v 1.18 2007/09/02 15:19:34 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)rs.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: rs.c,v 1.17 2006/04/17 09:45:00 moritz Exp $";
+static const char rcsid[] = "$OpenBSD: rs.c,v 1.18 2007/09/02 15:19:34 deraadt Exp $";
#endif
#endif /* not lint */
@@ -281,7 +281,7 @@ prepfile(void)
*ep = *(ep - nelem);
nelem = lp - elem;
}
- if (!(colwidths = (short *) malloc(ocols * sizeof(short))))
+ if (!(colwidths = (short *) calloc(ocols, sizeof(short))))
errx(1, "malloc: No gutter space");
if (flags & SQUEEZE) {
if (flags & TRANSPOSE)