aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/dynamic_cfg.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-19 13:25:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-19 13:25:58 +0000
commit8fd4189a09d89cbd49527282eeb9360858a24148 (patch)
tree768cd84f44c0b4f71001e7bb03134cf67c41df4c /src/libserver/dynamic_cfg.c
parentc4a0536e2b3622cb953e8b6ad2be53c723512bae (diff)
downloadrspamd-8fd4189a09d89cbd49527282eeb9360858a24148.tar.gz
rspamd-8fd4189a09d89cbd49527282eeb9360858a24148.zip
[Fix] Make dynamic conf more NaN aware
Diffstat (limited to 'src/libserver/dynamic_cfg.c')
-rw-r--r--src/libserver/dynamic_cfg.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index 3f0d490f4..121158526 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -21,6 +21,8 @@
#include "unix-std.h"
#include "lua/lua_common.h"
+#include <math.h>
+
struct config_json_buf {
GString *buf;
struct rspamd_config *cfg;
@@ -95,9 +97,11 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
ucl_object_iter_t nit = NULL;
while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
- if (ucl_object_lookup (it_val, "name") &&
- ucl_object_lookup (it_val, "value")) {
- name = ucl_object_tostring (ucl_object_lookup (it_val, "name"));
+ const ucl_object_t *n = ucl_object_lookup (it_val, "name");
+ const ucl_object_t *v = ucl_object_lookup (it_val, "value");
+
+ if (n != NULL && v != NULL) {
+ name = ucl_object_tostring (n);
if (!name || !rspamd_action_from_str (name, &test_act)) {
msg_err ("unknown action: %s",
@@ -105,8 +109,15 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
"name")));
continue;
}
- nscore = ucl_object_todouble (ucl_object_lookup (it_val,
- "value"));
+
+
+ if (ucl_object_type (v) == UCL_NULL) {
+ nscore = NAN;
+ }
+ else {
+ nscore = ucl_object_todouble (v);
+ }
+
rspamd_config_set_action_score (cfg, name, nscore, priority);
}
else {