Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/patch PR/53368: Thomas Barabosch: Potential integer ...



details:   https://anonhg.NetBSD.org/src/rev/9c92a1f54149
branches:  trunk
changeset: 833235:9c92a1f54149
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 16 00:40:14 2018 +0000

description:
PR/53368: Thomas Barabosch: Potential integer overflow in usr.bin/patch/inp.c

diffstat:

 usr.bin/patch/inp.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (44 lines):

diff -r 1746cb7e30eb -r 9c92a1f54149 usr.bin/patch/inp.c
--- a/usr.bin/patch/inp.c       Sat Jun 16 00:19:42 2018 +0000
+++ b/usr.bin/patch/inp.c       Sat Jun 16 00:40:14 2018 +0000
@@ -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 @@
 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 @@
                return false;
        }
        *lines_allocated = new_size;
-       i_ptr = p;
        return true;
 }
 



Home | Main Index | Thread Index | Old Index