Source-Changes-HG archive

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

[src/netbsd-7-1]: src/usr.sbin/mtree Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/2247912955f7
branches:  netbsd-7-1
changeset: 800808:2247912955f7
user:      snj <snj%NetBSD.org@localhost>
date:      Mon Oct 23 18:34:52 2017 +0000

description:
Pull up following revision(s) (requested by nakayama in ticket #1506):
        usr.sbin/mtree/only.c: revision 1.3
Don't modify strings stored in hash, otherwise filling up of
directory hierarchy stops if the same hash value occurs in
directory and leaf.
Fix the issue that
"./usr/share/locale/pl/LC_MESSAGES/gettext-tools.mo" isn't included
in sets file in the case of MKUNPRIVED=no.

diffstat:

 usr.sbin/mtree/only.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 035208262093 -r 2247912955f7 usr.sbin/mtree/only.c
--- a/usr.sbin/mtree/only.c     Tue Oct 17 15:51:18 2017 +0000
+++ b/usr.sbin/mtree/only.c     Mon Oct 23 18:34:52 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $        */
+/*     $NetBSD: only.c,v 1.2.22.1 2017/10/23 18:34:52 snj Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include <sys/cdefs.h>
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $");
+__RCSID("$NetBSD: only.c,v 1.2.22.1 2017/10/23 18:34:52 snj Exp $");
 #endif
 
 #include <sys/param.h>
@@ -89,11 +89,14 @@
 hash_insert(char *str, uint32_t h)
 {
        struct hentry *e;
+       char *x;
 
        if ((e = malloc(sizeof(*e))) == NULL)
                mtree_err("memory allocation error");
+       if ((x = strdup(str)) == NULL)
+               mtree_err("memory allocation error");
 
-       e->str = str;
+       e->str = x;
        e->hash = h;
        e->next = table[h];
        table[h] = e;
@@ -110,10 +113,7 @@
 
        *ptr = '\0';
        if (!hash_find(str, &h)) {
-               char *x = strdup(str);
-               if (x == NULL)
-                       mtree_err("memory allocation error");
-               hash_insert(x, h);
+               hash_insert(str, h);
                fill(str);
        }
        *ptr = '/';
@@ -135,6 +135,7 @@
                        err(1, "Duplicate entry %s", line);
                hash_insert(line, h);
                fill(line);
+               free(line);
        }
 
        fclose(fp);



Home | Main Index | Thread Index | Old Index