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/ddaf826776d0
branches:  trunk
changeset: 457622:ddaf826776d0
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 bb42614b38cd -r ddaf826776d0 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