summaryrefslogtreecommitdiff
path: root/usr.bin/awk/run.c
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2014-10-11 03:08:27 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2014-10-11 03:08:27 +0000
commit1a7eef7a38b0f9441fcef01e7d2fde0601d00041 (patch)
tree431ff2621d300714efa5de6e5509448cdb16ea5d /usr.bin/awk/run.c
parentd74a29af9d37b529c12d4a9c8b69ed7948fb5cb2 (diff)
Userland reallocarray() audit.
Avoid potential integer overflow in the size argument of malloc() and realloc() by using reallocarray() to avoid unchecked multiplication. ok deraadt@
Diffstat (limited to 'usr.bin/awk/run.c')
-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));