From cdc100b748c784d1c8e55aee647dfed53b6df893 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 12 Jun 2018 15:13:03 +0100 Subject: [PATCH] [Fix] Fix dynamic settings application Issue: #769 Closes: #769 --- src/libserver/dynamic_cfg.c | 8 ++++++-- src/plugins/lua/dynamic_conf.lua | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c index 121158526..584590ed9 100644 --- a/src/libserver/dynamic_cfg.c +++ b/src/libserver/dynamic_cfg.c @@ -152,7 +152,6 @@ json_config_read_cb (gchar * chunk, if (data->cur_data == NULL) { jb = g_malloc0 (sizeof (*jb)); jb->cfg = pd->cfg; - jb->buf = pd->buf; data->cur_data = jb; } else { @@ -161,7 +160,7 @@ json_config_read_cb (gchar * chunk, if (jb->buf == NULL) { /* Allocate memory for buffer */ - jb->buf = g_string_sized_new (BUFSIZ); + jb->buf = g_string_sized_new (MAX (len, BUFSIZ)); } g_string_append_len (jb->buf, chunk, len); @@ -179,6 +178,10 @@ json_config_fin_cb (struct map_cb_data *data) if (data->prev_data) { jb = data->prev_data; /* Clean prev data */ + if (jb->buf) { + g_string_free (jb->buf, TRUE); + } + g_free (jb); } @@ -190,6 +193,7 @@ json_config_fin_cb (struct map_cb_data *data) msg_err ("no data read"); return; } + if (jb->buf == NULL) { msg_err ("no data read"); return; diff --git a/src/plugins/lua/dynamic_conf.lua b/src/plugins/lua/dynamic_conf.lua index 29f63e90c..ffe1f7e9c 100644 --- a/src/plugins/lua/dynamic_conf.lua +++ b/src/plugins/lua/dynamic_conf.lua @@ -319,10 +319,15 @@ local function add_dynamic_action(_, act, score) return add end -if redis_params then - rspamd_plugins["dynamic_conf"] = { - add_symbol = add_dynamic_symbol, - add_action = add_dynamic_action, - } - lua_util.disable_module(N, "redis") -end +if section then + if redis_params then + rspamd_plugins["dynamic_conf"] = { + add_symbol = add_dynamic_symbol, + add_action = add_dynamic_action, + } + else + lua_util.disable_module(N, "redis") + end +else + lua_util.disable_module(N, "config") +end \ No newline at end of file -- 2.39.5