From 7e02198e95665a06fa53542bdb098bca76192ccd Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 23 Apr 2004 16:33:51 +0000 Subject: [PATCH] Fix username/groupname cache so it returns a name that was just looked up by get{pw,gr}id(). Otherwise, it returns a NULL name unless it's already in the cache. Credit to Juergen Lock. --- usr.bin/tar/write.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 527df2b710f..2d097fae7e4 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -1113,6 +1113,7 @@ lookup_uname(struct bsdtar *bsdtar, uid_t uid) } else if (pwent->pw_name != NULL && pwent->pw_name[0] != '\0') { cache->cache[slot].name = strdup(pwent->pw_name); cache->cache[slot].id = uid; + return (cache->cache[slot].name); } return (NULL); } @@ -1146,6 +1147,7 @@ lookup_gname(struct bsdtar *bsdtar, gid_t gid) } else if (grent->gr_name != NULL && grent->gr_name[0] != '\0') { cache->cache[slot].name = strdup(grent->gr_name); cache->cache[slot].id = gid; + return (cache->cache[slot].name); } return (NULL); }