Skip to content

Commit 912b7d7

Browse files
graphaelliedsiper
authored andcommitted
out_es: create space for header before use
Signed-off-by: Gil Raphaelli <graphaelli@gmail.com>
1 parent 74e0e51 commit 912b7d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

plugins/out_es/es.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,11 +890,13 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
890890
flb_http_basic_auth(c, ctx->cloud_user, ctx->cloud_passwd);
891891
}
892892
else if (ctx->http_api_key) {
893-
header_line = flb_sds_printf(NULL, "ApiKey %s", ctx->http_api_key);
893+
/* 7 for ApiKey + space */
894+
header_line = flb_sds_create_size(strlen(ctx->http_api_key)+7);
894895
if (header_line == NULL) {
895896
flb_plg_error(ctx->ins, "failed to format API key auth header");
896897
goto retry;
897898
}
899+
header_line = flb_sds_printf(&header_line, "ApiKey %s", ctx->http_api_key);
898900

899901
if (flb_http_add_header(c,
900902
FLB_HTTP_HEADER_AUTH, strlen(FLB_HTTP_HEADER_AUTH),

0 commit comments

Comments
 (0)