Patch 8.0.1671
Problem: Crash when passing non-dict argument as env to job_start().
Solution: Check for valid argument. (Ozaki Kiichi, closes #2765)
Files: src/channel.c, src/testdir/test_channel.vim
*** ../vim-8.0.1670/src/channel.c 2018-04-03 12:50:55.509298311 +0200
--- src/channel.c 2018-04-07 13:16:03.576867619 +0200
***************
*** 4797,4805 ****
{
if (!(supported2 & JO2_ENV))
break;
opt->jo_set2 |= JO2_ENV;
opt->jo_env = item->vval.v_dict;
! ++item->vval.v_dict->dv_refcount;
}
else if (STRCMP(hi->hi_key, "cwd") == 0)
{
--- 4797,4811 ----
{
if (!(supported2 & JO2_ENV))
break;
+ if (item->v_type != VAR_DICT)
+ {
+ EMSG2(_(e_invargval), "env");
+ return FAIL;
+ }
opt->jo_set2 |= JO2_ENV;
opt->jo_env = item->vval.v_dict;
! if (opt->jo_env != NULL)
! ++opt->jo_env->dv_refcount;
}
else if (STRCMP(hi->hi_key, "cwd") == 0)
{
*** ../vim-8.0.1670/src/testdir/test_channel.vim 2018-04-05
22:44:33.775423796 +0200
--- src/testdir/test_channel.vim 2018-04-07 13:16:03.576867619 +0200
***************
*** 1720,1729 ****
let g:envstr = ''
if has('win32')
! call job_start(['cmd', '/c', 'echo %FOO%'], {'callback':
{ch,msg->execute(":let g:envstr .= msg")}, 'env':{'FOO': 'bar'}})
else
! call job_start([&shell, &shellcmdflag, 'echo $FOO'], {'callback':
{ch,msg->execute(":let g:envstr .= msg")}, 'env':{'FOO': 'bar'}})
endif
call WaitFor('"" != g:envstr')
call assert_equal("bar", g:envstr)
unlet g:envstr
--- 1720,1731 ----
let g:envstr = ''
if has('win32')
! let cmd = ['cmd', '/c', 'echo %FOO%']
else
! let cmd = [&shell, &shellcmdflag, 'echo $FOO']
endif
+ call assert_fails('call job_start(cmd, {"env": 1})', 'E475:')
+ call job_start(cmd, {'callback': {ch,msg -> execute(":let g:envstr .=
msg")}, 'env': {'FOO': 'bar'}})
call WaitFor('"" != g:envstr')
call assert_equal("bar", g:envstr)
unlet g:envstr
***************
*** 1737,1747 ****
let g:envstr = ''
if has('win32')
let expect = $TEMP
! let job = job_start(['cmd', '/c', 'echo %CD%'], {'callback':
{ch,msg->execute(":let g:envstr .= msg")}, 'cwd': expect})
else
let expect = $HOME
! let job = job_start(['pwd'], {'callback': {ch,msg->execute(":let g:envstr
.= msg")}, 'cwd': expect})
endif
try
call WaitFor('"" != g:envstr')
let expect = substitute(expect, '[/\\]$', '', '')
--- 1739,1750 ----
let g:envstr = ''
if has('win32')
let expect = $TEMP
! let cmd = ['cmd', '/c', 'echo %CD%']
else
let expect = $HOME
! let cmd = ['pwd']
endif
+ let job = job_start(cmd, {'callback': {ch,msg -> execute(":let g:envstr .=
msg")}, 'cwd': expect})
try
call WaitFor('"" != g:envstr')
let expect = substitute(expect, '[/\\]$', '', '')
*** ../vim-8.0.1670/src/version.c 2018-04-07 10:42:09.725521193 +0200
--- src/version.c 2018-04-07 13:19:27.207814603 +0200
***************
*** 764,765 ****
--- 764,767 ----
{ /* Add new patch number below this line */
+ /**/
+ 1671,
/**/
--
An actual excerpt from a classified section of a city newspaper:
"Illiterate? Write today for free help!"
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.