Skip to content

Commit

Permalink
explicitly test set[ug]id() return values
Browse files Browse the repository at this point in the history
Legacy !_POSIX_SAVED_IDS path only; coverity report via Ed Maste
ok dtucker@
  • Loading branch information
djmdjm committed Sep 13, 2019
1 parent 91a2135 commit c17e463
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions uidswap.c
Expand Up @@ -162,8 +162,10 @@ restore_uid(void)
* Propagate the real uid (usually more privileged) to effective uid
* as well.
*/
setuid(getuid());
setgid(getgid());
if (setuid(getuid()) == -1)
fatal("%s: setuid failed: %s", __func__, strerror(errno));
if (setgid(getgid()) == -1)
fatal("%s: setgid failed: %s", __func__, strerror(errno));
#endif /* SAVED_IDS_WORK_WITH_SETEUID */

if (setgroups(saved_egroupslen, saved_egroups) == -1)
Expand Down

0 comments on commit c17e463

Please sign in to comment.