summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-21 21:07:29 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-21 21:07:29 +0200
commitb109bb4e1208753cb286b39992b58126d5aa4ce6 (patch)
tree7240a2e9d334af6953bacbc2ae73de7446d84fde
parenteef0531621c8d4045d669eb815b051d925983df8 (diff)
patch 8.0.0980: Coverity warning for failing to open /dev/nullv8.0.0980
Problem: Coverity warning for failing to open /dev/null. Solution: When /dev/null can't be opened exit the child.
-rw-r--r--src/os_unix.c8
-rw-r--r--src/version.c2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 57b0dcdd9a..de0bb311dc 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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)
{
diff --git a/src/version.c b/src/version.c
index 5d97014c01..c8ae29752c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 980,
+/**/
979,
/**/
978,