mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 7.4.1616
Problem: Malformed channel request causes a hang. Solution: Drop malformed message. (Damien)
This commit is contained in:
parent
829c8e3696
commit
ac74d5e86c
@ -1480,11 +1480,19 @@ channel_parse_json(channel_T *channel, int part)
|
|||||||
/* Put the unread part back into the channel.
|
/* Put the unread part back into the channel.
|
||||||
* TODO: insert in front */
|
* TODO: insert in front */
|
||||||
if (reader.js_buf[reader.js_used] != NUL)
|
if (reader.js_buf[reader.js_used] != NUL)
|
||||||
|
{
|
||||||
|
if (ret == FAIL)
|
||||||
|
{
|
||||||
|
ch_error(channel, "Decoding failed - discarding input");
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
channel_save(channel, part, reader.js_buf + reader.js_used,
|
channel_save(channel, part, reader.js_buf + reader.js_used,
|
||||||
(int)(reader.js_end - reader.js_buf) - reader.js_used);
|
(int)(reader.js_end - reader.js_buf) - reader.js_used);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
|
||||||
@ -1586,12 +1594,14 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv)
|
|||||||
|
|
||||||
if (STRCMP(cmd, "ex") == 0)
|
if (STRCMP(cmd, "ex") == 0)
|
||||||
{
|
{
|
||||||
|
ch_logs(channel, "Executing ex command '%s'", (char *)arg);
|
||||||
do_cmdline_cmd(arg);
|
do_cmdline_cmd(arg);
|
||||||
}
|
}
|
||||||
else if (STRCMP(cmd, "normal") == 0)
|
else if (STRCMP(cmd, "normal") == 0)
|
||||||
{
|
{
|
||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
|
|
||||||
|
ch_logs(channel, "Executing normal command '%s'", (char *)arg);
|
||||||
ea.arg = arg;
|
ea.arg = arg;
|
||||||
ea.addr_count = 0;
|
ea.addr_count = 0;
|
||||||
ea.forceit = TRUE; /* no mapping */
|
ea.forceit = TRUE; /* no mapping */
|
||||||
@ -1601,6 +1611,7 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv)
|
|||||||
{
|
{
|
||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
|
|
||||||
|
ch_log(channel, "redraw");
|
||||||
ea.forceit = *arg != NUL;
|
ea.forceit = *arg != NUL;
|
||||||
ex_redraw(&ea);
|
ex_redraw(&ea);
|
||||||
showruler(FALSE);
|
showruler(FALSE);
|
||||||
@ -1642,11 +1653,18 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv)
|
|||||||
/* Don't pollute the display with errors. */
|
/* Don't pollute the display with errors. */
|
||||||
++emsg_skip;
|
++emsg_skip;
|
||||||
if (!is_call)
|
if (!is_call)
|
||||||
|
{
|
||||||
|
ch_logs(channel, "Evaluating expression '%s'", (char *)arg);
|
||||||
tv = eval_expr(arg, NULL);
|
tv = eval_expr(arg, NULL);
|
||||||
else if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch_logs(channel, "Calling '%s'", (char *)arg);
|
||||||
|
if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK)
|
||||||
tv = &res_tv;
|
tv = &res_tv;
|
||||||
else
|
else
|
||||||
tv = NULL;
|
tv = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (argv[id_idx].v_type == VAR_NUMBER)
|
if (argv[id_idx].v_type == VAR_NUMBER)
|
||||||
{
|
{
|
||||||
@ -1848,10 +1866,7 @@ may_invoke_callback(channel_T *channel, int part)
|
|||||||
|
|
||||||
if (argv[0].v_type == VAR_STRING)
|
if (argv[0].v_type == VAR_STRING)
|
||||||
{
|
{
|
||||||
char_u *cmd = argv[0].vval.v_string;
|
|
||||||
|
|
||||||
/* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */
|
/* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */
|
||||||
ch_logs(channel, "Executing %s command", (char *)cmd);
|
|
||||||
channel_exe_cmd(channel, part, argv);
|
channel_exe_cmd(channel, part, argv);
|
||||||
free_tv(listtv);
|
free_tv(listtv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -104,6 +104,11 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||||||
print("sending: {}".format(cmd))
|
print("sending: {}".format(cmd))
|
||||||
self.request.sendall(cmd.encode('utf-8'))
|
self.request.sendall(cmd.encode('utf-8'))
|
||||||
response = "ok"
|
response = "ok"
|
||||||
|
elif decoded[1] == 'malformed':
|
||||||
|
cmd = '["ex",":"]wrong!["ex","smi"]'
|
||||||
|
print("sending: {}".format(cmd))
|
||||||
|
self.request.sendall(cmd.encode('utf-8'))
|
||||||
|
response = "ok"
|
||||||
elif decoded[1] == 'an expr':
|
elif decoded[1] == 'an expr':
|
||||||
# Send an expr request.
|
# Send an expr request.
|
||||||
cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]'
|
cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]'
|
||||||
|
@ -123,10 +123,12 @@ func s:communicate(port)
|
|||||||
" check that no job is handled correctly
|
" check that no job is handled correctly
|
||||||
call assert_equal('no process', string(ch_getjob(handle)))
|
call assert_equal('no process', string(ch_getjob(handle)))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Simple string request and reply.
|
" Simple string request and reply.
|
||||||
call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
|
call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
|
||||||
|
|
||||||
|
" Malformed command should be ignored.
|
||||||
|
call assert_equal('ok', ch_evalexpr(handle, 'malformed'))
|
||||||
|
|
||||||
" Request that triggers sending two ex commands. These will usually be
|
" Request that triggers sending two ex commands. These will usually be
|
||||||
" handled before getting the response, but it's not guaranteed, thus wait a
|
" handled before getting the response, but it's not guaranteed, thus wait a
|
||||||
" tiny bit for the commands to get executed.
|
" tiny bit for the commands to get executed.
|
||||||
|
@ -748,6 +748,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1616,
|
||||||
/**/
|
/**/
|
||||||
1615,
|
1615,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user