summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-10-19 16:53:39 +0200
committerBram Moolenaar <Bram@vim.org>2018-10-19 16:53:39 +0200
commit839e81e12d81377f74ffc03f8645ce52cbc18b13 (patch)
tree2d01fe4dd88ccd631ca24441ffa6c4825b9b3619
parent38654503b04dd5ff4813f81892d9f62db1ff01b9 (diff)
downloadvim-git-8.1.0485.tar.gz
patch 8.1.0485: term_start() does not check if directory is accessiblev8.1.0485
Problem: term_start() does not check if directory is accessible. Solution: Add mch_access() call. (Jason Franklin)
-rw-r--r--src/channel.c3
-rw-r--r--src/testdir/test_terminal.vim22
-rw-r--r--src/version.c2
3 files changed, 26 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c
index aa0a0d38c..02ed3a8fc 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -4916,7 +4916,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
if (!(supported2 & JO2_CWD))
break;
opt->jo_cwd = get_tv_string_buf_chk(item, opt->jo_cwd_buf);
- if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd))
+ if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd)
+ || mch_access((char *)opt->jo_cwd, X_OK) != 0)
{
EMSG2(_(e_invargval), "cwd");
return FAIL;
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index b82dae13e..235cd3160 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -478,6 +478,28 @@ func Test_terminal_cwd()
call delete('Xdir', 'rf')
endfunc
+func Test_terminal_cwd_failure()
+ " Case 1: Provided directory is not actually a directory. Attempt to make
+ " the file executable as well.
+ call writefile([], 'Xfile')
+ call setfperm('Xfile', 'rwx------')
+ call assert_fails("call term_start(&shell, {'cwd': 'Xfile'})", 'E475:')
+ call delete('Xfile')
+
+ " Case 2: Directory does not exist.
+ call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
+
+ " Case 3: Directory exists but is not accessible.
+ call mkdir('Xdir', '', '0600')
+ " return early if the directory permissions could not be set properly
+ if getfperm('Xdir')[2] == 'x'
+ call delete('Xdir', 'rf')
+ return
+ endif
+ call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
+ call delete('Xdir', 'rf')
+endfunc
+
func Test_terminal_servername()
if !has('clientserver')
return
diff --git a/src/version.c b/src/version.c
index ab54bb312..4ed8adc26 100644
--- a/src/version.c
+++ b/src/version.c
@@ -793,6 +793,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 485,
+/**/
484,
/**/
483,