To: vim_dev@googlegroups.com Subject: Patch 7.4.1255 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1255 Problem: Crash for channel "eval" command without third argument. Solution: Check for missing argument. Files: src/channel.c, src/testdir/test_channel.vim, src/testdir/test_channel.py *** ../vim-7.4.1254/src/channel.c 2016-02-03 23:25:03.291954920 +0100 --- src/channel.c 2016-02-03 23:51:44.327052937 +0100 *************** *** 694,700 **** { int is_eval = cmd[1] == 'v'; ! if (is_eval && arg3->v_type != VAR_NUMBER) { if (p_verbose > 2) EMSG("E904: third argument for eval must be a number"); --- 694,700 ---- { int is_eval = cmd[1] == 'v'; ! if (is_eval && (arg3 == NULL || arg3->v_type != VAR_NUMBER)) { if (p_verbose > 2) EMSG("E904: third argument for eval must be a number"); *************** *** 774,780 **** typval_T *arg3 = NULL; char_u *cmd = typetv->vval.v_string; ! /* ["cmd", arg] */ if (list->lv_len == 3) arg3 = &list->lv_last->li_tv; channel_exe_cmd(idx, cmd, &argv[1], arg3); --- 774,780 ---- typval_T *arg3 = NULL; char_u *cmd = typetv->vval.v_string; ! /* ["cmd", arg] or ["cmd", arg, arg] */ if (list->lv_len == 3) arg3 = &list->lv_last->li_tv; channel_exe_cmd(idx, cmd, &argv[1], arg3); *** ../vim-7.4.1254/src/testdir/test_channel.vim 2016-02-03 23:25:03.295954878 +0100 --- src/testdir/test_channel.vim 2016-02-03 23:56:01.564350023 +0100 *************** *** 90,95 **** --- 90,99 ---- call assert_equal('ok', ch_sendexpr(handle, 'eval-fails')) call assert_equal([-2, 'ERROR'], ch_sendexpr(handle, 'eval-result')) + " Send a bad eval request. There will be no response. + call assert_equal('ok', ch_sendexpr(handle, 'eval-bad')) + call assert_equal([-2, 'ERROR'], ch_sendexpr(handle, 'eval-result')) + " make the server quit, can't check if this works, should not hang. call ch_sendexpr(handle, '!quit!', 0) *** ../vim-7.4.1254/src/testdir/test_channel.py 2016-02-03 23:25:03.295954878 +0100 --- src/testdir/test_channel.py 2016-02-03 23:55:17.352814596 +0100 *************** *** 68,75 **** # simply send back a string response = "got it" elif decoded[1] == 'make change': ! # Send two ex commands at the same time, before replying to ! # the request. cmd = '["ex","call append(\\"$\\",\\"added1\\")"]' cmd += '["ex","call append(\\"$\\",\\"added2\\")"]' print("sending: {}".format(cmd)) --- 68,75 ---- # simply send back a string response = "got it" elif decoded[1] == 'make change': ! # Send two ex commands at the same time, before ! # replying to the request. cmd = '["ex","call append(\\"$\\",\\"added1\\")"]' cmd += '["ex","call append(\\"$\\",\\"added2\\")"]' print("sending: {}".format(cmd)) *************** *** 87,92 **** --- 87,98 ---- print("sending: {}".format(cmd)) self.request.sendall(cmd.encode('utf-8')) response = "ok" + elif decoded[1] == 'eval-bad': + # Send an eval request missing the third argument. + cmd = '["eval","xxx"]' + print("sending: {}".format(cmd)) + self.request.sendall(cmd.encode('utf-8')) + response = "ok" elif decoded[1] == 'eval-result': # Send back the last received eval result. response = last_eval *** ../vim-7.4.1254/src/version.c 2016-02-03 23:25:03.295954878 +0100 --- src/version.c 2016-02-03 23:52:56.690292612 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 1255, /**/ -- hundred-and-one symptoms of being an internet addict: 126. You brag to all of your friends about your date Saturday night...but you don't tell them it was only in a chat room. /// 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 ///