summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2018-06-16 00:40:14 +0000
committerchristos <christos@NetBSD.org>2018-06-16 00:40:14 +0000
commit2b359480f950f9cd3099c43cf7b61aa8fd5fa8eb (patch)
tree9042ec6666f4336dc898423993d769bb03658510 /usr.bin/patch
parent062601d1d91b920bbb6e19cf0b8971434e5c8183 (diff)
PR/53368: Thomas Barabosch: Potential integer overflow in usr.bin/patch/inp.c
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/inp.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index ae4611999d9..b456bcaeb6c 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
/*
* $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $
* $DragonFly: src/usr.bin/patch/inp.c,v 1.6 2007/09/29 23:11:10 swildner Exp $
- * $NetBSD: inp.c,v 1.24 2015/07/24 18:56:00 christos Exp $
+ * $NetBSD: inp.c,v 1.25 2018/06/16 00:40:14 christos Exp $
*/
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: inp.c,v 1.24 2015/07/24 18:56:00 christos Exp $");
+__RCSID("$NetBSD: inp.c,v 1.25 2018/06/16 00:40:14 christos Exp $");
#include <sys/types.h>
#include <sys/file.h>
@@ -118,12 +118,11 @@ scan_input(const char *filename)
static bool
reallocate_lines(size_t *lines_allocated)
{
- char **p;
size_t new_size;
new_size = *lines_allocated * 3 / 2;
- p = realloc(i_ptr, (new_size + 2) * sizeof(char *));
- if (p == NULL) { /* shucks, it was a near thing */
+ int res = reallocarr(&i_ptr, new_size + 2, sizeof(char *));
+ if (res != 0) { /* shucks, it was a near thing */
munmap(i_womp, i_size);
i_womp = NULL;
free(i_ptr);
@@ -132,7 +131,6 @@ reallocate_lines(size_t *lines_allocated)
return false;
}
*lines_allocated = new_size;
- i_ptr = p;
return true;
}