diff --git a/plugins/in_tail/tail_config.c b/plugins/in_tail/tail_config.c index be28410dc4a..e5095b254ad 100644 --- a/plugins/in_tail/tail_config.c +++ b/plugins/in_tail/tail_config.c @@ -77,6 +77,18 @@ static int multiline_load_parsers(struct flb_tail_config *ctx) return 0; } +static void adjust_buffer_for_2bytes_alignments(struct flb_tail_config *ctx) +{ + if ((ctx->buf_max_size - 1) % 2) { + ctx->buf_max_size++; + flb_plg_info(ctx->ins, "adjusted buf_max_size to %zd", ctx->buf_max_size); + } + if ((ctx->buf_chunk_size - 1) % 2) { + ctx->buf_chunk_size++; + flb_plg_info(ctx->ins, "adjusted buf_chunk_size to %zd", ctx->buf_chunk_size); + } +} + struct flb_tail_config *flb_tail_config_create(struct flb_input_instance *ins, struct flb_config *config) { @@ -190,14 +202,17 @@ struct flb_tail_config *flb_tail_config_create(struct flb_input_instance *ins, if (tmp) { if (strcasecmp(tmp, "auto") == 0) { ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UNICODE_AUTO; + adjust_buffer_for_2bytes_alignments(ctx); } else if (strcasecmp(tmp, "utf-16le") == 0 || strcasecmp(tmp, "utf16-le") == 0) { ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_LE; + adjust_buffer_for_2bytes_alignments(ctx); } else if (strcasecmp(tmp, "utf-16be") == 0 || strcasecmp(tmp, "utf16-be") == 0) { ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_BE; + adjust_buffer_for_2bytes_alignments(ctx); } else { flb_plg_error(ctx->ins, "invalid encoding 'unicode.encoding' value");