diff --git a/tunnels/client/protobuf/protobuf_client.c b/tunnels/client/protobuf/protobuf_client.c index 0a152e8d..2ec242a9 100644 --- a/tunnels/client/protobuf/protobuf_client.c +++ b/tunnels/client/protobuf/protobuf_client.c @@ -100,6 +100,8 @@ static void downStream(tunnel_t *self, context_t *c) size_t bytes_passed = readUleb128ToUint64(uleb_data, uleb_data + bufLen(full_data), &data_len); if (data_len == 0 || (bufLen(full_data) - (bytes_passed)) < data_len) { + shiftl(full_data, 1); // bring the data back to its original form + bufferStreamPush(bstream, full_data); destroyContext(c); return; @@ -167,6 +169,7 @@ static void downStream(tunnel_t *self, context_t *c) context_t *send_flow_ctx = newContextFrom(c); send_flow_ctx->payload = flowctl_buf; self->up->upStream(self->up, send_flow_ctx); + if (! isAlive(c->line)) { reuseBuffer(getContextBufferPool(c), full_data); diff --git a/tunnels/server/protobuf/protobuf_server.c b/tunnels/server/protobuf/protobuf_server.c index 700ae993..5e761dc4 100644 --- a/tunnels/server/protobuf/protobuf_server.c +++ b/tunnels/server/protobuf/protobuf_server.c @@ -63,11 +63,14 @@ static void upStream(tunnel_t *self, context_t *c) readUI8(full_data, &flags); shiftr(full_data, 1); // first byte is (protobuf flag) - const uint8_t *uleb_data = rawBuf(full_data); // first byte is \n (protobuf) + const uint8_t *uleb_data = rawBuf(full_data); uint64_t data_len = 0; size_t bytes_passed = readUleb128ToUint64(uleb_data, uleb_data + bufLen(full_data), &data_len); + if (data_len == 0 || (bufLen(full_data) - (bytes_passed)) < data_len) { + shiftl(full_data, 1); // bring the data back to its original form + bufferStreamPush(bstream, full_data); destroyContext(c); return;