Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Properly zero new memory after reallocating...



details:   https://anonhg.NetBSD.org/src/rev/14da3f119190
branches:  trunk
changeset: 962247:14da3f119190
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Jul 08 19:36:02 2019 +0000

description:
Properly zero new memory after reallocating the timezone menu

diffstat:

 usr.sbin/sysinst/util.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 9c8850233022 -r 14da3f119190 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Mon Jul 08 06:45:01 2019 +0000
+++ b/usr.sbin/sysinst/util.c   Mon Jul 08 19:36:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.25 2019/06/22 20:46:07 christos Exp $       */
+/*     $NetBSD: util.c,v 1.26 2019/07/08 19:36:02 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1351,14 +1351,20 @@
                        if (stat(zoneinfo_dir, &sb) == -1)
                                continue;
                        if (nfiles >= maxfiles) {
-                               p = realloc(tz_menu, 2 * maxfiles * sizeof *tz_menu);
+                               p = realloc(tz_menu,
+                                   2 * maxfiles * sizeof *tz_menu);
                                if (p == NULL)
                                        break;
                                tz_menu = p;
-                               p = realloc(tz_names, 2 * maxfiles * sizeof *tz_names);
+                               memset(tz_menu + maxfiles, 0,
+                                   maxfiles * sizeof *tz_menu);
+                               p = realloc(tz_names,
+                                   2 * maxfiles * sizeof *tz_names);
                                if (p == NULL)
                                        break;
                                tz_names = p;
+                               memset(tz_names + maxfiles, 0,
+                                   maxfiles * sizeof *tz_names);
                                maxfiles *= 2;
                        }
                        if (S_ISREG(sb.st_mode))



Home | Main Index | Thread Index | Old Index