libarchive: Initialize passwd/group lookup result
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.
This commit is contained in:
parent
d6fe0438c1
commit
76f8504596
|
@ -199,6 +199,7 @@ lookup_uname_helper(struct name_cache *cache, id_t id)
|
||||||
if (cache->buff == NULL)
|
if (cache->buff == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
result = &pwent; /* Old getpwuid_r ignores last argument. */
|
||||||
r = getpwuid_r((uid_t)id, &pwent,
|
r = getpwuid_r((uid_t)id, &pwent,
|
||||||
cache->buff, cache->buff_size, &result);
|
cache->buff, cache->buff_size, &result);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
|
@ -247,6 +248,7 @@ lookup_gname_helper(struct name_cache *cache, id_t id)
|
||||||
if (cache->buff == NULL)
|
if (cache->buff == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
result = &grent; /* Old getgrgid_r ignores last argument. */
|
||||||
r = getgrgid_r((gid_t)id, &grent,
|
r = getgrgid_r((gid_t)id, &grent,
|
||||||
cache->buff, cache->buff_size, &result);
|
cache->buff, cache->buff_size, &result);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
|
|
|
@ -129,6 +129,7 @@ lookup_gid(void *private_data, const char *gname, gid_t gid)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
result = &grent; /* Old getgrnam_r ignores last argument. */
|
||||||
r = getgrnam_r(gname, &grent, buffer, bufsize, &result);
|
r = getgrnam_r(gname, &grent, buffer, bufsize, &result);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -188,6 +189,7 @@ lookup_uid(void *private_data, const char *uname, uid_t uid)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
result = &pwent; /* Old getpwnam_r ignores last argument. */
|
||||||
r = getpwnam_r(uname, &pwent, buffer, bufsize, &result);
|
r = getpwnam_r(uname, &pwent, buffer, bufsize, &result);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue