To: vim_dev@googlegroups.com Subject: Patch 8.1.0485 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0485 Problem: term_start() does not check if directory is accessible. Solution: Add mch_access() call. (Jason Franklin) Files: src/channel.c, src/testdir/test_terminal.vim *** ../vim-8.1.0484/src/channel.c 2018-09-13 15:33:39.601712271 +0200 --- src/channel.c 2018-10-19 16:52:39.981396959 +0200 *************** *** 4916,4922 **** 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)) { EMSG2(_(e_invargval), "cwd"); return FAIL; --- 4916,4923 ---- 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) ! || mch_access((char *)opt->jo_cwd, X_OK) != 0) { EMSG2(_(e_invargval), "cwd"); return FAIL; *** ../vim-8.1.0484/src/testdir/test_terminal.vim 2018-08-07 16:33:15.255728441 +0200 --- src/testdir/test_terminal.vim 2018-10-19 16:52:03.413741075 +0200 *************** *** 478,483 **** --- 478,505 ---- 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 *** ../vim-8.1.0484/src/version.c 2018-10-19 16:26:39.964404727 +0200 --- src/version.c 2018-10-19 16:50:33.270601082 +0200 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 485, /**/ -- hundred-and-one symptoms of being an internet addict: 241. You try to look for Net Search even when you're in File Manager. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///