Skip to content

Commit

Permalink
ls(1): Fix trivial SEGV due to NULL deref in OOM path
Browse files Browse the repository at this point in the history
Reported by:	Anton Rang <rang AT acm.org>
Sponsored by:	Dell EMC Isilon
  • Loading branch information
cemeyer committed May 5, 2020
1 parent b34f841 commit 530d2d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bin/ls/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,21 @@ display(const FTSENT *p, FTSENT *list, int options)
group = ngroup;
} else {
user = user_from_uid(sp->st_uid, 0);
/*
* user_from_uid(..., 0) only returns
* NULL in OOM conditions. We could
* format the uid here, but (1) in
* general ls(1) exits on OOM, and (2)
* there is another allocation/exit
* path directly below, which will
* likely exit anyway.
*/
if (user == NULL)
err(1, "user_from_uid");
group = group_from_gid(sp->st_gid, 0);
/* Ditto. */
if (group == NULL)
err(1, "group_from_gid");
}
if ((ulen = strlen(user)) > maxuser)
maxuser = ulen;
Expand Down

0 comments on commit 530d2d6

Please sign in to comment.