From: Damien Miller Date: Fri, 13 Sep 2019 03:12:42 +0000 (+1000) Subject: explicitly test set[ug]id() return values X-Git-Tag: V_8_1_P1~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c17e4638e5592688264fc0349f61bfc7b4425aa5;p=thirdparty%2Fopenssh-portable.git explicitly test set[ug]id() return values Legacy !_POSIX_SAVED_IDS path only; coverity report via Ed Maste ok dtucker@ --- diff --git a/uidswap.c b/uidswap.c index 1d78c607a..40e121503 100644 --- 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)