Skip to content

Commit

Permalink
in_forward: increase the buffer size to buffer_max_size
Browse files Browse the repository at this point in the history
 If conn->buf_size is no space to add buffer_chunk_size,
 the size to realloc should be buffer_max_size.

Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored and edsiper committed Dec 12, 2021
1 parent a580e20 commit 4e75acd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/in_forward/fw_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ int fw_conn_event(void *data)
if (event->mask & MK_EVENT_READ) {
available = (conn->buf_size - conn->buf_len);
if (available < 1) {
if (conn->buf_size + ctx->buffer_chunk_size > ctx->buffer_max_size) {
if (conn->buf_size >= ctx->buffer_max_size) {
flb_plg_warn(ctx->ins, "fd=%i incoming data exceed limit (%lu bytes)",
event->fd, (ctx->buffer_max_size));
fw_conn_del(conn);
return -1;
}

size = conn->buf_size + ctx->buffer_chunk_size;
else if (conn->buf_size + ctx->buffer_chunk_size > ctx->buffer_max_size) {
/* no space to add buffer_chunk_size */
/* set maximum size */
size = ctx->buffer_max_size;
}
else {
size = conn->buf_size + ctx->buffer_chunk_size;
}
tmp = flb_realloc(conn->buf, size);
if (!tmp) {
flb_errno();
Expand Down

0 comments on commit 4e75acd

Please sign in to comment.