summaryrefslogtreecommitdiff
path: root/usr.bin/window
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/window
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/window')
-rw-r--r--usr.bin/window/compress.c20
-rw-r--r--usr.bin/window/wwinit.c6
-rw-r--r--usr.bin/window/wwopen.c6
-rw-r--r--usr.bin/window/wwsize.c6
-rw-r--r--usr.bin/window/xx.c6
5 files changed, 22 insertions, 22 deletions
diff --git a/usr.bin/window/compress.c b/usr.bin/window/compress.c
index 059909bf107..776e1bc4ffa 100644
--- a/usr.bin/window/compress.c
+++ b/usr.bin/window/compress.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compress.c,v 1.7 2003/07/10 00:06:52 david Exp $ */
+/* $OpenBSD: compress.c,v 1.8 2007/09/02 15:19:35 deraadt Exp $ */
/* $NetBSD: compress.c,v 1.3 1995/09/28 10:34:13 tls Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)compress.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: compress.c,v 1.7 2003/07/10 00:06:52 david Exp $";
+static char rcsid[] = "$OpenBSD: compress.c,v 1.8 2007/09/02 15:19:35 deraadt Exp $";
#endif
#endif /* not lint */
@@ -238,29 +238,29 @@ ccinit()
#endif
#undef C
if ((cc_output = (struct cc **)
- malloc(cc_bufsize * sizeof *cc_output)) == 0)
+ calloc(cc_bufsize, sizeof *cc_output)) == 0)
goto nomem;
if ((cc_hashcodes = (short *)
- malloc(cc_bufsize * sizeof *cc_hashcodes)) == 0)
+ calloc(cc_bufsize, sizeof *cc_hashcodes)) == 0)
goto nomem;
- if ((cc_htab = (struct cc **) malloc(HSIZE * sizeof *cc_htab)) == 0)
+ if ((cc_htab = (struct cc **) calloc(HSIZE, sizeof *cc_htab)) == 0)
goto nomem;
if ((cc_tokens = (struct cc **)
- malloc((cc_ntoken + tt.tt_token_max - tt.tt_token_min + 1) *
- sizeof *cc_tokens)) == 0)
+ malloc(cc_ntoken + tt.tt_token_max - tt.tt_token_min + 1),
+ sizeof *cc_tokens) == 0)
goto nomem;
if ((cc_undo = (struct cc_undo *)
- malloc(cc_bufsize * sizeof *cc_undo)) == 0)
+ calloc(cc_bufsize, sizeof *cc_undo)) == 0)
goto nomem;
for (i = tt.tt_token_min; i <= tt.tt_token_max; i++)
if ((cc_places[i] = (short *)
- malloc(cc_bufsize * sizeof **cc_places)) == 0)
+ calloc(cc_bufsize, sizeof **cc_places)) == 0)
goto nomem;
cc_q0a.qforw = cc_q0a.qback = &cc_q0a;
cc_q0b.qforw = cc_q0b.qback = &cc_q0b;
cc_q1a.qforw = cc_q1a.qback = &cc_q1a;
cc_q1b.qforw = cc_q1b.qback = &cc_q1b;
- if ((p = (struct cc *) malloc(cc_ntoken * sizeof *p)) == 0)
+ if ((p = (struct cc *) calloc(cc_ntoken, sizeof *p)) == 0)
goto nomem;
for (i = 0; i < tt.tt_ntoken; i++) {
p->code = i;
diff --git a/usr.bin/window/wwinit.c b/usr.bin/window/wwinit.c
index aee8ea603df..81407abebbd 100644
--- a/usr.bin/window/wwinit.c
+++ b/usr.bin/window/wwinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wwinit.c,v 1.17 2006/01/02 16:20:56 millert Exp $ */
+/* $OpenBSD: wwinit.c,v 1.18 2007/09/02 15:19:35 deraadt Exp $ */
/* $NetBSD: wwinit.c,v 1.11 1996/02/08 21:49:07 mycroft Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)wwinit.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: wwinit.c,v 1.17 2006/01/02 16:20:56 millert Exp $";
+static char rcsid[] = "$OpenBSD: wwinit.c,v 1.18 2007/09/02 15:19:35 deraadt Exp $";
#endif
#endif /* not lint */
@@ -265,7 +265,7 @@ wwinit()
for (i = 0; i < wwnrow; i++)
wwtouched[i] = 0;
- wwupd = (struct ww_update *) malloc(wwnrow * sizeof *wwupd);
+ wwupd = (struct ww_update *) calloc(wwnrow, sizeof *wwupd);
if (wwupd == 0) {
wwerrno = WWE_NOMEM;
goto bad;
diff --git a/usr.bin/window/wwopen.c b/usr.bin/window/wwopen.c
index 804da4a96c0..c10f39191b9 100644
--- a/usr.bin/window/wwopen.c
+++ b/usr.bin/window/wwopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wwopen.c,v 1.10 2003/07/10 00:06:52 david Exp $ */
+/* $OpenBSD: wwopen.c,v 1.11 2007/09/02 15:19:35 deraadt Exp $ */
/* $NetBSD: wwopen.c,v 1.6 1996/02/08 21:08:04 mycroft Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)wwopen.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: wwopen.c,v 1.10 2003/07/10 00:06:52 david Exp $";
+static char rcsid[] = "$OpenBSD: wwopen.c,v 1.11 2007/09/02 15:19:35 deraadt Exp $";
#endif
#endif /* not lint */
@@ -165,7 +165,7 @@ wwopen(type, oflags, nrow, ncol, row, col, nline)
for (j = w->ww_b.l; j < w->ww_b.r; j++)
w->ww_buf[i][j].c_w = ' ';
- w->ww_nvis = (short *)malloc(w->ww_w.nr * sizeof (short));
+ w->ww_nvis = (short *)calloc(w->ww_w.nr, sizeof (short));
if (w->ww_nvis == 0) {
wwerrno = WWE_NOMEM;
goto bad;
diff --git a/usr.bin/window/wwsize.c b/usr.bin/window/wwsize.c
index 9d51ce82aba..3fa81533825 100644
--- a/usr.bin/window/wwsize.c
+++ b/usr.bin/window/wwsize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wwsize.c,v 1.8 2003/06/03 02:56:23 millert Exp $ */
+/* $OpenBSD: wwsize.c,v 1.9 2007/09/02 15:19:36 deraadt Exp $ */
/* $NetBSD: wwsize.c,v 1.5 1996/02/08 20:45:11 mycroft Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)wwsize.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: wwsize.c,v 1.8 2003/06/03 02:56:23 millert Exp $";
+static char rcsid[] = "$OpenBSD: wwsize.c,v 1.9 2007/09/02 15:19:36 deraadt Exp $";
#endif
#endif /* not lint */
@@ -76,7 +76,7 @@ struct ww *w;
if (buf == 0)
goto bad;
}
- nvis = (short *)malloc(nrow * sizeof (short));
+ nvis = (short *)calloc(nrow, sizeof (short));
if (nvis == 0) {
wwerrno = WWE_NOMEM;
goto bad;
diff --git a/usr.bin/window/xx.c b/usr.bin/window/xx.c
index c6037991772..96288d0c055 100644
--- a/usr.bin/window/xx.c
+++ b/usr.bin/window/xx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xx.c,v 1.7 2003/07/18 23:11:43 david Exp $ */
+/* $OpenBSD: xx.c,v 1.8 2007/09/02 15:19:36 deraadt Exp $ */
/* $NetBSD: xx.c,v 1.3 1995/09/28 10:36:03 tls Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)xx.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: xx.c,v 1.7 2003/07/18 23:11:43 david Exp $";
+static char rcsid[] = "$OpenBSD: xx.c,v 1.8 2007/09/02 15:19:36 deraadt Exp $";
#endif
#endif /* not lint */
@@ -55,7 +55,7 @@ xxinit()
/* ccinit may choose to change xxbufsize */
if (tt.tt_ntoken > 0 && ccinit() < 0)
return -1;
- xxbuf = malloc(xxbufsize * sizeof *xxbuf);
+ xxbuf = calloc(xxbufsize, sizeof *xxbuf);
if (xxbuf == 0) {
wwerrno = WWE_NOMEM;
return -1;