Skip to content

Commit

Permalink
in_syslog: fix buffer handling in UDP mode
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Apr 24, 2018
1 parent d5f72b5 commit 3d3a53f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/in_syslog/syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ static int in_syslog_collect_udp(struct flb_input_instance *i_ins,
struct flb_syslog *ctx = in_context;
(void) i_ins;

bytes = recvfrom(ctx->server_fd, buf, sizeof(buf), 0, NULL, NULL);
bytes = recvfrom(ctx->server_fd, buf, sizeof(buf) - 1, 0, NULL, NULL);
if (bytes > 0) {
buf[bytes] = '\0';
syslog_prot_process_udp(buf, bytes, ctx);
}
else {
Expand Down
4 changes: 4 additions & 0 deletions plugins/in_syslog/syslog_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ int syslog_prot_process_udp(char *buf, size_t size, struct flb_syslog *ctx)
out_sbuf = &ctx->i_ins->mp_sbuf;
out_pck = &ctx->i_ins->mp_pck;

flb_input_buf_write_start(ctx->i_ins);

ret = flb_parser_do(ctx->parser, buf, size,
&out_buf, &out_size, &out_time);
if (ret >= 0) {
Expand All @@ -146,5 +148,7 @@ int syslog_prot_process_udp(char *buf, size_t size, struct flb_syslog *ctx)
return -1;
}

flb_input_buf_write_end(ctx->i_ins);

return 0;
}

0 comments on commit 3d3a53f

Please sign in to comment.