From 3cacdae04443d4ad5cb5cfc2de112d4f6ea40385 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 24 Oct 2014 07:25:18 -0300 Subject: channel: fix `REQ` definition for msgpack-rpc logging --- src/nvim/msgpack_rpc/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 3325b294dd..1fe9d7aedb 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -730,7 +730,7 @@ static WBuffer *serialize_response(uint64_t channel_id, } #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL -#define REQ "[response] " +#define REQ "[request] " #define RES "[response] " #define NOT "[notification] " -- cgit From 4d70fe89bfff783363165025f25a4a42f624f1f1 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 24 Oct 2014 10:15:13 -0300 Subject: msgpack-rpc: Terminate server->client calls when the channel closes --- src/nvim/msgpack_rpc/channel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 1fe9d7aedb..43bed54b2c 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -338,6 +338,8 @@ static void parse_msgpack(RStream *rstream, void *data, bool eof) if (eof) { close_channel(channel); + call_set_error(channel, "Channel was closed by the client"); + return; } size_t count = rstream_pending(rstream); -- cgit From c95bc3349b6df13d8a4b5c1c7f3440e4578b266c Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 28 Oct 2014 09:17:57 -0300 Subject: input: Fix conversion error in `convert_input()` The `rbuffer_consumed` was being passed a consumed count from another buffer, causing integer overflow in `rbuffer_relocate`. Fixes #1343 --- src/nvim/os/input.c | 16 +++++++++++----- src/nvim/os/rstream.c | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 2c8026d099..e4501aeb82 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -237,18 +238,23 @@ static void convert_input(void) if (convert) { // Perform input conversion according to `input_conv` - size_t unconverted_length; + size_t unconverted_length = 0; data = (char *)string_convert_ext(&input_conv, (uint8_t *)data, (int *)&converted_length, (int *)&unconverted_length); - data_length = rbuffer_pending(read_buffer) - unconverted_length; + data_length -= unconverted_length; } - // Write processed data to input buffer - size_t consumed = rbuffer_write(input_buffer, data, data_length); + // The conversion code will be gone eventually, for now assume `input_buffer` + // always has space for the converted data(it's many times the size of + // `read_buffer`, so it's hard to imagine a scenario where the converted data + // doesn't fit) + assert(converted_length <= rbuffer_available(input_buffer)); + // Write processed data to input buffer. + (void)rbuffer_write(input_buffer, data, converted_length); // Adjust raw buffer pointers - rbuffer_consumed(read_buffer, consumed); + rbuffer_consumed(read_buffer, data_length); if (convert) { // data points to memory allocated by `string_convert_ext`, free it. diff --git a/src/nvim/os/rstream.c b/src/nvim/os/rstream.c index d96b3d931c..beff404fd0 100644 --- a/src/nvim/os/rstream.c +++ b/src/nvim/os/rstream.c @@ -396,6 +396,7 @@ static void close_cb(uv_handle_t *handle) static void rbuffer_relocate(RBuffer *rbuffer) { + assert(rbuffer->rpos <= rbuffer->wpos); // Move data ... memmove( rbuffer->data, // ...to the beginning of the buffer(rpos 0) -- cgit