]> granicus.if.org Git - sudo/commitdiff
Cast the return value of fcntl() to void when setting FD_CLOEXEC.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 May 2016 22:16:24 +0000 (16:16 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 May 2016 22:16:24 +0000 (16:16 -0600)
Coverity CID 104063, 104064, 104069, 104070, 104071, 104072, 104073, 104074

plugins/sudoers/iolog.c
plugins/sudoers/match.c
plugins/sudoers/tsgetgrpw.c
src/exec.c
src/exec_pty.c
src/sudo.c

index adcc055246a0a78afc4e8a81cec3994335b68cab..0c040320461e9ed55a42bfcaff6559f4826b8862 100644 (file)
@@ -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");
index fdbe2628eb686cb934336ec53c6d1089e1a9fbc1..bc0b50906a29538b836deeffef8268d590bde099 100644 (file)
@@ -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);
index 04bfdbda7d1e55748de80dffab18c34c8acadfa1..7c89e6b163c9cc212f50de15fe1bb6b7f49deab0 100644 (file)
@@ -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);
     }
index 31c3bd5ce1a06ac9eaa66111f8bb909325bc5d26..c0128512d3ca08f88e214822e8600ce851c44517 100644 (file)
@@ -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);
index 80800737eae4ee6b2fb590ba3595bf563f91da73..96e2423b5d7ff63e7d6c51a6954b49bc202deb0e 100644 (file)
@@ -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 */
index a53bb797c692e6ba5b846e730861576b6fd3bce0..c4c85c4993b841c49066b2af039c29fcdb14ae53 100644 (file)
@@ -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;