Updated patch is attached.

1. mch_isdir() is added back
2. test is extended to make sure that term_start() fails with a file for
   cwd value

Thanks,
Jason

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
>From ce39bc19ebdf7500b2d8efc6cb4f5448102b014f Mon Sep 17 00:00:00 2001
From: Jason Franklin <j_...@fastmail.us>
Date: Mon, 15 Oct 2018 16:13:29 -0400
Subject: [PATCH] Check for directory access with term_start() cwd

---
 src/channel.c                 |  3 ++-
 src/testdir/test_terminal.vim | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/channel.c b/src/channel.c
index aa0a0d38c..55f79fd9f 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..fcefef5fd 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -478,6 +478,31 @@ 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 is not accessible.
+  call mkdir('Xdir', '', '0600')
+
+  " Return early if the directory permissions were not 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
-- 
2.17.1

Raspunde prin e-mail lui