From 6473d55aa7be4665f21cc29d2289fb5a482a1405 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 5 May 2016 16:16:24 -0600 Subject: [PATCH] Cast the return value of fcntl() to void when setting FD_CLOEXEC. Coverity CID 104063, 104064, 104069, 104070, 104071, 104072, 104073, 104074 --- plugins/sudoers/iolog.c | 2 +- plugins/sudoers/match.c | 2 +- plugins/sudoers/tsgetgrpw.c | 12 ++++++------ src/exec.c | 2 +- src/exec_pty.c | 4 ++-- src/sudo.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index adcc05524..0c0403204 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -330,7 +330,7 @@ open_io_fd(char *pathbuf, size_t len, struct io_log_file *iol, bool docompress) if (iol->enabled) { fd = open(pathbuf, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR); if (fd != -1) { - fcntl(fd, F_SETFD, FD_CLOEXEC); + (void)fcntl(fd, F_SETFD, FD_CLOEXEC); #ifdef HAVE_ZLIB_H if (docompress) iol->fd.g = gzdopen(fd, "w"); diff --git a/plugins/sudoers/match.c b/plugins/sudoers/match.c index fdbe2628e..bc0b50906 100644 --- a/plugins/sudoers/match.c +++ b/plugins/sudoers/match.c @@ -684,7 +684,7 @@ digest_matches(const char *file, const struct sudo_digest *sd, int *fd) * on exec flag on the fd for fexecve(2). */ if (!is_script) - fcntl(*fd, F_SETFD, FD_CLOEXEC); + (void)fcntl(*fd, F_SETFD, FD_CLOEXEC); #endif /* HAVE_FEXECVE */ fclose(fp); debug_return_bool(true); diff --git a/plugins/sudoers/tsgetgrpw.c b/plugins/sudoers/tsgetgrpw.c index 04bfdbda7..7c89e6b16 100644 --- a/plugins/sudoers/tsgetgrpw.c +++ b/plugins/sudoers/tsgetgrpw.c @@ -86,7 +86,7 @@ setpwent(void) if (pwf == NULL) { pwf = fopen(pwfile, "r"); if (pwf != NULL) - fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); } else { rewind(pwf); } @@ -163,7 +163,7 @@ getpwnam(const char *name) if (pwf == NULL) { if ((pwf = fopen(pwfile, "r")) == NULL) return NULL; - fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); } else { rewind(pwf); } @@ -186,7 +186,7 @@ getpwuid(uid_t uid) if (pwf == NULL) { if ((pwf = fopen(pwfile, "r")) == NULL) return NULL; - fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC); } else { rewind(pwf); } @@ -215,7 +215,7 @@ setgrent(void) if (grf == NULL) { grf = fopen(grfile, "r"); if (grf != NULL) - fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); } else { rewind(grf); } @@ -289,7 +289,7 @@ getgrnam(const char *name) if (grf == NULL) { if ((grf = fopen(grfile, "r")) == NULL) return NULL; - fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); } else { rewind(grf); } @@ -312,7 +312,7 @@ getgrgid(gid_t gid) if (grf == NULL) { if ((grf = fopen(grfile, "r")) == NULL) return NULL; - fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); + (void)fcntl(fileno(grf), F_SETFD, FD_CLOEXEC); } else { rewind(grf); } diff --git a/src/exec.c b/src/exec.c index 31c3bd5ce..c0128512d 100644 --- a/src/exec.c +++ b/src/exec.c @@ -131,7 +131,7 @@ fork_cmnd(struct command_details *details, int sv[2]) close(sv[0]); close(signal_pipe[0]); close(signal_pipe[1]); - fcntl(sv[1], F_SETFD, FD_CLOEXEC); + (void)fcntl(sv[1], F_SETFD, FD_CLOEXEC); exec_cmnd(details, &cstat, sv[1]); send(sv[1], &cstat, sizeof(cstat), 0); sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, 1); diff --git a/src/exec_pty.c b/src/exec_pty.c index 80800737e..96e2423b5 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -843,7 +843,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask) close(sv[0]); close(signal_pipe[0]); close(signal_pipe[1]); - fcntl(sv[1], F_SETFD, FD_CLOEXEC); + (void)fcntl(sv[1], F_SETFD, FD_CLOEXEC); sigprocmask(SIG_SETMASK, omask, NULL); /* Close the other end of the stdin/stdout/stderr pipes and exec. */ if (io_pipe[STDIN_FILENO][1]) @@ -1380,7 +1380,7 @@ exec_monitor(struct command_details *details, int backchannel) close(signal_pipe[0]); close(signal_pipe[1]); close(errpipe[0]); - fcntl(errpipe[1], F_SETFD, FD_CLOEXEC); + (void)fcntl(errpipe[1], F_SETFD, FD_CLOEXEC); restore_signals(); /* setup tty and exec command */ diff --git a/src/sudo.c b/src/sudo.c index a53bb797c..c4c85c499 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -669,7 +669,7 @@ command_info_to_details(char * const info[], struct command_details *details) add_preserved_fd(&details->preserved_fds, details->execfd); #else /* Plugin thinks we support fexecve() but we don't. */ - fcntl(details->execfd, F_SETFD, FD_CLOEXEC); + (void)fcntl(details->execfd, F_SETFD, FD_CLOEXEC); details->execfd = -1; #endif break; -- 2.40.0