bin/172289: Check return value of setuid()
Erik Cederstrand
erik at cederstrand.dk
Tue Oct 2 21:50:14 UTC 2012
The following reply was made to PR bin/172289; it has been noted by GNATS.
From: Erik Cederstrand <erik at cederstrand.dk>
To: bug-followup at FreeBSD.org,
Eitan Adler <lists at eitanadler.com>
Cc:
Subject: Re: bin/172289: Check return value of setuid()
Date: Tue, 2 Oct 2012 23:45:58 +0200
--Apple-Mail=_0AED8E4D-0FE1-4ACE-ADA5-9A2452E0E9E1
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
ping6 also lack check on return value, btw. Patch attached.
Erik
--Apple-Mail=_0AED8E4D-0FE1-4ACE-ADA5-9A2452E0E9E1
Content-Disposition: attachment;
filename=ping6.txt
Content-Type: text/plain;
name="ping6.txt"
Content-Transfer-Encoding: 7bit
Index: ping6.c
===================================================================
--- ping6.c (revision 240960)
+++ ping6.c (working copy)
@@ -702,8 +702,10 @@
}
/* 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");
--Apple-Mail=_0AED8E4D-0FE1-4ACE-ADA5-9A2452E0E9E1--
More information about the freebsd-bugs
mailing list