Check for dup2() failure.

This commit is contained in:
Todd C. Miller
2010-06-15 09:02:23 -04:00
parent 59718c32e4
commit c2f8d24f20
5 changed files with 40 additions and 28 deletions

View File

@@ -222,7 +222,10 @@ sudo_askpass(const char *askpass, const char *prompt)
if (pid == 0) {
/* child, point stdout to output side of the pipe and exec askpass */
(void) dup2(pfd[1], STDOUT_FILENO);
if (dup2(pfd[1], STDOUT_FILENO) == -1) {
warning("dup2");
_exit(255);
}
(void) setuid(ROOT_UID);
if (setgid(user_details.gid)) {
warning("unable to set gid to %u", (unsigned int)user_details.gid);