summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2014-10-11 03:07:29 +0000
committerdoug <doug@openbsd.org>2014-10-11 03:07:29 +0000
commit953dcc0d99ca4861a2320631702090abc5cfc3f6 (patch)
tree6add937442d4452380bcd99a61b0db9aa4b31a67
parentUserland reallocarray() audit. (diff)
downloadwireguard-openbsd-953dcc0d99ca4861a2320631702090abc5cfc3f6.tar.xz
wireguard-openbsd-953dcc0d99ca4861a2320631702090abc5cfc3f6.zip
Userland reallocarray() audit.
Avoid potential integer overflow in the size argument of malloc() and realloc() by using reallocarray() to avoid unchecked multiplication. ok deraadt@
-rw-r--r--usr.bin/awk/run.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index 9bb85fd4fe2..9e8bb42aba7 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.34 2013/09/29 15:42:25 deraadt Exp $ */
+/* $OpenBSD: run.c,v 1.35 2014/10/11 03:07:29 doug Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -1738,7 +1738,7 @@ FILE *openfile(int a, const char *us)
if (i >= nfiles) {
struct files *nf;
int nnf = nfiles + FOPEN_MAX;
- nf = realloc(files, nnf * sizeof(*nf));
+ nf = reallocarray(files, nnf, sizeof(*nf));
if (nf == NULL)
FATAL("cannot grow files for %s and %d files", s, nnf);
memset(&nf[nfiles], 0, FOPEN_MAX * sizeof(*nf));