summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/inp.c
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2014-10-08 04:06:23 +0000
committerdoug <doug@openbsd.org>2014-10-08 04:06:23 +0000
commitc905b2617f2672181a099d8df3fa499ef3abdcf9 (patch)
tree334b49cfe71d7b028cb94ed6b80a98e1aa4a7f2f /usr.bin/patch/inp.c
parentuserland reallocarray audit. (diff)
downloadwireguard-openbsd-c905b2617f2672181a099d8df3fa499ef3abdcf9.tar.xz
wireguard-openbsd-c905b2617f2672181a099d8df3fa499ef3abdcf9.zip
userland reallocarray audit.
Replace malloc() and realloc() calls that may have integer overflow in the multiplication of the size argument with reallocarray(). ok deraadt@
Diffstat (limited to 'usr.bin/patch/inp.c')
-rw-r--r--usr.bin/patch/inp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 67cc3a83d72..15712c9d926 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inp.c,v 1.37 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: inp.c,v 1.38 2014/10/08 04:06:23 doug Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -111,7 +111,7 @@ reallocate_lines(size_t *lines_allocated)
size_t new_size;
new_size = *lines_allocated * 3 / 2;
- p = realloc(i_ptr, (new_size + 2) * sizeof(char *));
+ p = reallocarray(i_ptr, new_size + 2, sizeof(char *));
if (p == NULL) { /* shucks, it was a near thing */
munmap(i_womp, i_size);
i_womp = NULL;