From df9abd97ac98d8bf50c06548eedcd8a69600243e Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 19 Jun 2017 07:02:52 +0000 Subject: [PATCH] Check return value of seteuid() and bail out if we fail. MFC after: 2 weeks --- usr.sbin/rpc.lockd/lock_proc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpc.lockd/lock_proc.c b/usr.sbin/rpc.lockd/lock_proc.c index 595d6254769c..3b040e5f14a0 100644 --- a/usr.sbin/rpc.lockd/lock_proc.c +++ b/usr.sbin/rpc.lockd/lock_proc.c @@ -276,7 +276,10 @@ get_client(struct sockaddr *host_addr, rpcvers_t vers) /* Regain root privileges, for bindresvport. */ old_euid = geteuid(); - seteuid(0); + if (seteuid(0) != 0) { + syslog(LOG_ERR, "seteuid(0) failed"); + return NULL; + } /* * Bind the client FD to a reserved port. @@ -285,7 +288,10 @@ get_client(struct sockaddr *host_addr, rpcvers_t vers) bindresvport(clnt_fd, NULL); /* Drop root privileges again. */ - seteuid(old_euid); + if (seteuid(old_euid) != 0) { + syslog(LOG_ERR, "seteuid(%d) failed", old_euid); + return NULL; + } /* Success - update the cache entry */ clnt_cache_ptr[clnt_cache_next_to_use] = client;