Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions libopenbsd/pwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ gid_from_group(const char *name, gid_t *gid)
const char *
group_from_gid(gid_t gid, int nogroup)
{

return (getgrgid(gid)->gr_name);
if (getgrgid(gid) != NULL)
return (getgrgid(gid)->gr_name);
return (getgrgid(nogroup)->gr_name);
}

int
Expand All @@ -43,6 +44,7 @@ uid_from_user(const char *name, uid_t *uid)
const char *
user_from_uid(uid_t uid, int nouser)
{

return (getpwuid(uid)->pw_name);
if (getpwuid(uid) != NULL)
return (getpwuid(uid)->pw_name);
return (getpwuid(nouser)->pw_name);
}
4 changes: 2 additions & 2 deletions ls/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ display(FTSENT *p, FTSENT *list)
user = nuser;
group = ngroup;
} else {
user = getpwuid(sp->st_uid)->pw_name;
group = getgrgid(sp->st_gid)->gr_name;
user = user_from_uid(sp->st_uid, 0);
group = group_from_gid(sp->st_gid, 0);
}
if ((ulen = strlen(user)) > maxuser)
maxuser = ulen;
Expand Down