]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
explicitly test set[ug]id() return values
authorDamien Miller <djm@mindrot.org>
Fri, 13 Sep 2019 03:12:42 +0000 (13:12 +1000)
committerDamien Miller <djm@mindrot.org>
Fri, 13 Sep 2019 03:15:14 +0000 (13:15 +1000)
Legacy !_POSIX_SAVED_IDS path only; coverity report via Ed Maste
ok dtucker@

uidswap.c

index 1d78c607ab61d96498f82b035efbfdf23fd16f50..40e1215039e33dc3192632037e172236be80af1b 100644 (file)
--- a/uidswap.c
+++ b/uidswap.c
@@ -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)