From 2acc44904ef75d10ac2896528c6fb7ee3a9c92fd Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 3 Dec 2024 18:48:40 +0900 Subject: [PATCH] in_forward: Handle '' and "" or absent value for yaml value as an empty shared_key Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw_config.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/in_forward/fw_config.c b/plugins/in_forward/fw_config.c index b3a22931ffd..c6260b8f1b6 100644 --- a/plugins/in_forward/fw_config.c +++ b/plugins/in_forward/fw_config.c @@ -88,10 +88,21 @@ struct flb_in_fw_config *fw_config_init(struct flb_input_instance *i_ins) /* Shared Key */ p = flb_input_get_property("shared_key", i_ins); if (p) { - config->shared_key = flb_sds_create(p); + if (strcmp(p, "\'\'") == 0 || strcmp(p, "\"\"") == 0) { + config->shared_key = flb_sds_create(""); + } + else { + config->shared_key = flb_sds_create(p); + } } else { - config->shared_key = NULL; + config->shared_key = flb_sds_create(""); + } + if (config->shared_key == NULL) { + flb_plg_error(i_ins, "could not initialize shared_key"); + fw_config_destroy(config); + + return NULL; } /* Self Hostname */