Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/pkg_install/dist/create pkg_install-20190405



details:   https://anonhg.NetBSD.org/src/rev/9d404ef48e28
branches:  trunk
changeset: 840422:9d404ef48e28
user:      sevan <sevan%NetBSD.org@localhost>
date:      Fri Apr 05 23:41:58 2019 +0000

description:
pkg_install-20190405

diffstat:

 external/bsd/pkg_install/dist/create/util.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r 976e90737b62 -r 9d404ef48e28 external/bsd/pkg_install/dist/create/util.c
--- a/external/bsd/pkg_install/dist/create/util.c       Fri Apr 05 23:09:18 2019 +0000
+++ b/external/bsd/pkg_install/dist/create/util.c       Fri Apr 05 23:41:58 2019 +0000
@@ -65,7 +65,7 @@
                        errx(2, "user %s unknown", file->owner);
                file->st.st_uid = uid;
        } else {
-               file->owner = user_from_uid(file->st.st_uid, 1);
+               file->owner = xstrdup(user_from_uid(file->st.st_uid, 1));
        }
 
        if (file->group != NULL) {
@@ -73,10 +73,9 @@
 
                if (gid_from_group(file->group, &gid) == -1)
                        errx(2, "group %s unknown", file->group);
-               file->group = file->group;
                file->st.st_gid = gid;
        } else {
-               file->group = group_from_gid(file->st.st_gid, 1);
+               file->group = xstrdup(group_from_gid(file->st.st_gid, 1));
        }
 }
 
@@ -88,8 +87,8 @@
 
        file = xmalloc(sizeof(*file));
        file->name = archive_name;
-       file->owner = owner;
-       file->group = group;
+       file->owner = (owner != NULL) ? xstrdup(owner) : NULL;
+       file->group = (group != NULL) ? xstrdup(group) : NULL;
        file->data = data;
        file->len = len;
 
@@ -116,8 +115,8 @@
 
        file = xmalloc(sizeof(*file));
        file->name = archive_name;
-       file->owner = owner;
-       file->group = group;
+       file->owner = (owner != NULL) ? xstrdup(owner) : NULL;
+       file->group = (group != NULL) ? xstrdup(group) : NULL;
        file->mode = mode;
 
        fd = open(disk_name, O_RDONLY);
@@ -148,6 +147,8 @@
 free_memory_file(struct memory_file *file)
 {
        if (file != NULL) {
+               free((char *)file->owner);
+               free((char *)file->group);
                free(file->data);
                free(file);
        }



Home | Main Index | Thread Index | Old Index