comparison src/channel.c @ 8653:d80edead9675 v7.4.1616

commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 20 14:31:00 2016 +0100 patch 7.4.1616 Problem: Malformed channel request causes a hang. Solution: Drop malformed message. (Damien)
author Christian Brabandt <cb@256bit.org>
date Sun, 20 Mar 2016 14:45:04 +0100
parents d762390fb27b
children 1eb302bf2475
comparison
equal deleted inserted replaced
8652:73a5940e5002 8653:d80edead9675
1479 1479
1480 /* Put the unread part back into the channel. 1480 /* Put the unread part back into the channel.
1481 * TODO: insert in front */ 1481 * TODO: insert in front */
1482 if (reader.js_buf[reader.js_used] != NUL) 1482 if (reader.js_buf[reader.js_used] != NUL)
1483 { 1483 {
1484 channel_save(channel, part, reader.js_buf + reader.js_used, 1484 if (ret == FAIL)
1485 (int)(reader.js_end - reader.js_buf) - reader.js_used); 1485 {
1486 ret = TRUE; 1486 ch_error(channel, "Decoding failed - discarding input");
1487 ret = FALSE;
1488 }
1489 else
1490 {
1491 channel_save(channel, part, reader.js_buf + reader.js_used,
1492 (int)(reader.js_end - reader.js_buf) - reader.js_used);
1493 ret = TRUE;
1494 }
1487 } 1495 }
1488 else 1496 else
1489 ret = FALSE; 1497 ret = FALSE;
1490 1498
1491 vim_free(reader.js_buf); 1499 vim_free(reader.js_buf);
1584 if (arg == NULL) 1592 if (arg == NULL)
1585 arg = (char_u *)""; 1593 arg = (char_u *)"";
1586 1594
1587 if (STRCMP(cmd, "ex") == 0) 1595 if (STRCMP(cmd, "ex") == 0)
1588 { 1596 {
1597 ch_logs(channel, "Executing ex command '%s'", (char *)arg);
1589 do_cmdline_cmd(arg); 1598 do_cmdline_cmd(arg);
1590 } 1599 }
1591 else if (STRCMP(cmd, "normal") == 0) 1600 else if (STRCMP(cmd, "normal") == 0)
1592 { 1601 {
1593 exarg_T ea; 1602 exarg_T ea;
1594 1603
1604 ch_logs(channel, "Executing normal command '%s'", (char *)arg);
1595 ea.arg = arg; 1605 ea.arg = arg;
1596 ea.addr_count = 0; 1606 ea.addr_count = 0;
1597 ea.forceit = TRUE; /* no mapping */ 1607 ea.forceit = TRUE; /* no mapping */
1598 ex_normal(&ea); 1608 ex_normal(&ea);
1599 } 1609 }
1600 else if (STRCMP(cmd, "redraw") == 0) 1610 else if (STRCMP(cmd, "redraw") == 0)
1601 { 1611 {
1602 exarg_T ea; 1612 exarg_T ea;
1603 1613
1614 ch_log(channel, "redraw");
1604 ea.forceit = *arg != NUL; 1615 ea.forceit = *arg != NUL;
1605 ex_redraw(&ea); 1616 ex_redraw(&ea);
1606 showruler(FALSE); 1617 showruler(FALSE);
1607 setcursor(); 1618 setcursor();
1608 out_flush(); 1619 out_flush();
1640 char_u *json = NULL; 1651 char_u *json = NULL;
1641 1652
1642 /* Don't pollute the display with errors. */ 1653 /* Don't pollute the display with errors. */
1643 ++emsg_skip; 1654 ++emsg_skip;
1644 if (!is_call) 1655 if (!is_call)
1656 {
1657 ch_logs(channel, "Evaluating expression '%s'", (char *)arg);
1645 tv = eval_expr(arg, NULL); 1658 tv = eval_expr(arg, NULL);
1646 else if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK) 1659 }
1647 tv = &res_tv;
1648 else 1660 else
1649 tv = NULL; 1661 {
1662 ch_logs(channel, "Calling '%s'", (char *)arg);
1663 if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK)
1664 tv = &res_tv;
1665 else
1666 tv = NULL;
1667 }
1650 1668
1651 if (argv[id_idx].v_type == VAR_NUMBER) 1669 if (argv[id_idx].v_type == VAR_NUMBER)
1652 { 1670 {
1653 int id = argv[id_idx].vval.v_number; 1671 int id = argv[id_idx].vval.v_number;
1654 1672
1846 while (argc < CH_JSON_MAX_ARGS) 1864 while (argc < CH_JSON_MAX_ARGS)
1847 argv[argc++].v_type = VAR_UNKNOWN; 1865 argv[argc++].v_type = VAR_UNKNOWN;
1848 1866
1849 if (argv[0].v_type == VAR_STRING) 1867 if (argv[0].v_type == VAR_STRING)
1850 { 1868 {
1851 char_u *cmd = argv[0].vval.v_string;
1852
1853 /* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */ 1869 /* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */
1854 ch_logs(channel, "Executing %s command", (char *)cmd);
1855 channel_exe_cmd(channel, part, argv); 1870 channel_exe_cmd(channel, part, argv);
1856 free_tv(listtv); 1871 free_tv(listtv);
1857 return TRUE; 1872 return TRUE;
1858 } 1873 }
1859 1874