summaryrefslogtreecommitdiff
path: root/usr.bin/xargs
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/xargs
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r--usr.bin/xargs/xargs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 77c74df28d4..b63733afc98 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xargs.c,v 1.24 2005/11/01 04:52:59 deraadt Exp $ */
+/* $OpenBSD: xargs.c,v 1.25 2007/09/02 15:19:36 deraadt Exp $ */
/* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */
/*-
@@ -45,7 +45,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: xargs.c,v 1.24 2005/11/01 04:52:59 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: xargs.c,v 1.25 2007/09/02 15:19:36 deraadt Exp $";
#endif
#endif /* not lint */
@@ -200,7 +200,7 @@ main(int argc, char *argv[])
* NULL.
*/
linelen = 1 + argc + nargs + 1;
- if ((av = bxp = malloc(linelen * sizeof(char **))) == NULL)
+ if ((av = bxp = calloc(linelen, sizeof(char **))) == NULL)
err(1, NULL);
/*
@@ -423,7 +423,7 @@ prerun(int argc, char *argv[])
* Allocate memory to hold the argument list, and
* a NULL at the tail.
*/
- tmp = malloc((argc + 1) * sizeof(char**));
+ tmp = calloc(argc + 1, sizeof(char**));
if (tmp == NULL)
err(1, NULL);
tmp2 = tmp;