]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Initialize passwd/group lookup result
authorBrad King <brad.king@kitware.com>
Mon, 16 Nov 2009 16:29:18 +0000 (11:29 -0500)
committerBrad King <brad.king@kitware.com>
Mon, 16 Nov 2009 16:29:18 +0000 (11:29 -0500)
The "result" argument to functions get(pwu|grg)id_r and get(pw|gr)name_r
does not appear in the signatures provided on older platforms.  We set
the pointer to the result memory in case the function ignores it, thus
ensuring initialization.

SVN-Revision: 1658

libarchive/archive_read_disk_set_standard_lookup.c
libarchive/archive_write_disk_set_standard_lookup.c

index 60054f918f0f738e1f0eeb6624dc9c1ea2c26c73..dc2f67f8f07a6ed70ab9c8df00e38e37807bec11 100644 (file)
@@ -195,6 +195,7 @@ lookup_uname_helper(struct name_cache *cache, id_t id)
        if (cache->buff == NULL)
                return (NULL);
        for (;;) {
+               result = &pwent; /* Old getpwuid_r ignores last arg. */
                r = getpwuid_r((uid_t)id, &pwent,
                               cache->buff, cache->buff_size, &result);
                if (r == 0)
@@ -243,6 +244,7 @@ lookup_gname_helper(struct name_cache *cache, id_t id)
        if (cache->buff == NULL)
                return (NULL);
        for (;;) {
+               result = &grent; /* Old getgrgid_r ignores last arg. */
                r = getgrgid_r((gid_t)id, &grent,
                               cache->buff, cache->buff_size, &result);
                if (r == 0)
index e41d61b125656097e04b4fb0e872bea1c0025767..275979003b196937921a7d8bdd6b491d17ea4d17 100644 (file)
@@ -125,6 +125,7 @@ lookup_gid(void *private_data, const char *gname, gid_t gid)
                int r;
 
                for (;;) {
+                       result = &grent; /* Old getgrnam_r ignores last arg. */
                        r = getgrnam_r(gname, &grent, buffer, bufsize, &result);
                        if (r == 0)
                                break;
@@ -184,6 +185,7 @@ lookup_uid(void *private_data, const char *uname, uid_t uid)
                int r;
 
                for (;;) {
+                       result = &pwent; /* Old getpwnam_r ignores last arg. */
                        r = getpwnam_r(uname, &pwent, buffer, bufsize, &result);
                        if (r == 0)
                                break;