From 4bc19b04c5658de751c40ddf1399ab0dd1d895e7 Mon Sep 17 00:00:00 2001 From: eadler Date: Mon, 22 Oct 2012 03:31:22 +0000 Subject: Check the return error of set[ug]id. While this can never fail in the current version of FreeBSD, this isn't guarenteed by the API. Custom security modules, or future implementations of the setuid and setgid may fail. PR: bin/172289 PR: bin/172290 PR: bin/172291 Submittud by: Erik Cederstrand Discussed by: freebsd-security Approved by: cperciva MFC after: 1 week --- sbin/ping6/ping6.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sbin/ping6') diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 711561e..8c3e16b 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -702,8 +702,10 @@ main(int argc, char *argv[]) } /* revoke root privilege */ - seteuid(getuid()); - setuid(getuid()); + if (seteuid(getuid()) != 0) + err(1, "seteuid() failed"); + if (setuid(getuid()) != 0) + err(1, "setuid() failed"); if ((options & F_FLOOD) && (options & F_INTERVAL)) errx(1, "-f and -i incompatible options"); -- cgit v1.1