]> granicus.if.org Git - vim/commitdiff
patch 8.0.0980: Coverity warning for failing to open /dev/null v8.0.0980
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Aug 2017 19:07:29 +0000 (21:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Aug 2017 19:07:29 +0000 (21:07 +0200)
Problem:    Coverity warning for failing to open /dev/null.
Solution:   When /dev/null can't be opened exit the child.

src/os_unix.c
src/version.c

index 57b0dcdd9ab14bcffac5b01a535a92f56132759e..de0bb311dc2e24513fa32bcb73f4ac78ab63988c 100644 (file)
@@ -4340,6 +4340,7 @@ mch_call_shell(
 
 # define EXEC_FAILED 122    /* Exit code when shell didn't execute.  Don't use
                               127, some shells use that already */
+# define OPEN_NULL_FAILED 123 /* Exit code if /dev/null can't be opened */
 
     char_u     *newcmd;
     pid_t      pid;
@@ -5369,7 +5370,14 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
        }
 
        if (use_null_for_in || use_null_for_out || use_null_for_err)
+       {
            null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0);
+           if (null_fd < 0)
+           {
+               perror("opening /dev/null failed");
+               _exit(OPEN_NULL_FAILED);
+           }
+       }
 
        if (pty_slave_fd >= 0)
        {
index 5d97014c011613fcc3eaf007268c74624feeca40..c8ae29752c2ac4a24ad666f2dc36276afa04428b 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    980,
 /**/
     979,
 /**/