Skip to content

Commit

Permalink
fix special case
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jul 12, 2024
1 parent 8a91f85 commit 11c0aa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tunnels/client/protobuf/protobuf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tunnels/server/protobuf/protobuf_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 11c0aa7

Please sign in to comment.