From 3d3a53f6c936f38c772a40495c41a6540927b9e4 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 24 Apr 2018 13:45:14 -0600 Subject: [PATCH] in_syslog: fix buffer handling in UDP mode Signed-off-by: Eduardo Silva --- plugins/in_syslog/syslog.c | 3 ++- plugins/in_syslog/syslog_prot.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/in_syslog/syslog.c b/plugins/in_syslog/syslog.c index 68815622c4c..094e977a3be 100644 --- a/plugins/in_syslog/syslog.c +++ b/plugins/in_syslog/syslog.c @@ -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 { diff --git a/plugins/in_syslog/syslog_prot.c b/plugins/in_syslog/syslog_prot.c index 943b7660bcf..d7e56c552b4 100644 --- a/plugins/in_syslog/syslog_prot.c +++ b/plugins/in_syslog/syslog_prot.c @@ -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) { @@ -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; }