Check for dup2() failure.
This commit is contained in:
@@ -463,7 +463,7 @@ send_mail(const char *fmt, ...)
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
chdir("/");
|
||||
(void) chdir("/");
|
||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0644)) != -1) {
|
||||
(void) dup2(fd, STDIN_FILENO);
|
||||
(void) dup2(fd, STDOUT_FILENO);
|
||||
@@ -501,12 +501,15 @@ send_mail(const char *fmt, ...)
|
||||
|
||||
/* Child, set stdin to output side of the pipe */
|
||||
if (pfd[0] != STDIN_FILENO) {
|
||||
(void) dup2(pfd[0], STDIN_FILENO);
|
||||
if (dup2(pfd[0], STDIN_FILENO) != -1) {
|
||||
mysyslog(LOG_ERR, "cannot dup stdin: %m");
|
||||
_exit(127);
|
||||
}
|
||||
(void) close(pfd[0]);
|
||||
}
|
||||
(void) close(pfd[1]);
|
||||
|
||||
/* Build up an argv based the mailer path and flags */
|
||||
/* Build up an argv based on the mailer path and flags */
|
||||
mflags = estrdup(def_mailerflags);
|
||||
mpath = estrdup(def_mailerpath);
|
||||
if ((argv[0] = strrchr(mpath, ' ')))
|
||||
|
Reference in New Issue
Block a user