aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libserver/cfg_rcl.c68
-rw-r--r--src/libserver/cfg_utils.c19
-rw-r--r--src/plugins/regexp.c75
-rw-r--r--src/rspamadm/configtest.c2
4 files changed, 150 insertions, 14 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 3df4ce05d..b8f7b9738 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -381,40 +381,108 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
nshots = cfg->default_max_shots;
if ((elt = ucl_object_lookup (obj, "one_shot")) != NULL) {
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "one_shot attribute is not boolean for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
if (ucl_object_toboolean (elt)) {
nshots = 1;
}
}
if ((elt = ucl_object_lookup (obj, "any_shot")) != NULL) {
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "any_shot attribute is not boolean for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
if (ucl_object_toboolean (elt)) {
nshots = -1;
}
}
if ((elt = ucl_object_lookup (obj, "one_param")) != NULL) {
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "one_param attribute is not boolean for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
if (ucl_object_toboolean (elt)) {
flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
}
}
if ((elt = ucl_object_lookup (obj, "ignore")) != NULL) {
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "ignore attribute is not boolean for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
if (ucl_object_toboolean (elt)) {
flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
}
}
if ((elt = ucl_object_lookup (obj, "nshots")) != NULL) {
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "nshots attribute is not numeric for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
nshots = ucl_object_toint (elt);
}
elt = ucl_object_lookup_any (obj, "score", "weight", NULL);
if (elt) {
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "score attribute is not numeric for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
score = ucl_object_todouble (elt);
}
elt = ucl_object_lookup (obj, "priority");
if (elt) {
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "priority attribute is not numeric for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
priority = ucl_object_toint (elt);
}
else {
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 550e4b730..ec2e48786 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1470,6 +1470,7 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
module_t *mod, **pmod;
guint i = 0;
struct module_ctx *mod_ctx, *cur_ctx;
+ gboolean ret = TRUE;
/* Init all compiled modules */
@@ -1504,11 +1505,19 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
mod_ctx->enabled = rspamd_config_is_module_enabled (cfg, mod->name);
if (reconfig) {
- (void)mod->module_reconfig_func (cfg);
- msg_info_config ("reconfig of %s", mod->name);
+ if (!mod->module_reconfig_func (cfg)) {
+ msg_err_config ("reconfig of %s failed!", mod->name);
+ }
+ else {
+ msg_info_config ("reconfig of %s", mod->name);
+ }
+
}
else {
- (void)mod->module_config_func (cfg);
+ if (!mod->module_config_func (cfg)) {
+ msg_info_config ("config of %s failed!", mod->name);
+ ret = FALSE;
+ }
}
}
@@ -1519,7 +1528,9 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
cur = g_list_next (cur);
}
- return rspamd_init_lua_filters (cfg, 0);
+ ret = rspamd_init_lua_filters (cfg, 0) && ret;
+
+ return ret;
}
static void
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index b40c9c468..897bbd277 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -279,39 +279,96 @@ regexp_module_config (struct rspamd_config *cfg)
elt = ucl_object_lookup (value, "score");
if (elt) {
- score = ucl_object_todouble (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "score attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ score = ucl_object_todouble (elt);
+ }
}
elt = ucl_object_lookup (value, "one_shot");
if (elt) {
- if (ucl_object_toboolean (elt)) {
- nshots = 1;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "one_shot attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ nshots = 1;
+ }
}
}
if ((elt = ucl_object_lookup (value, "any_shot")) != NULL) {
- if (ucl_object_toboolean (elt)) {
- nshots = -1;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "any_shot attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ nshots = -1;
+ }
}
}
if ((elt = ucl_object_lookup (value, "nshots")) != NULL) {
- nshots = ucl_object_toint (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "nshots attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ nshots = ucl_object_toint (elt);
+ }
}
elt = ucl_object_lookup (value, "one_param");
if (elt) {
- if (ucl_object_toboolean (elt)) {
- flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "one_param attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
+ }
}
}
elt = ucl_object_lookup (value, "priority");
if (elt) {
- priority = ucl_object_toint (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "priority attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ priority = ucl_object_toint (elt);
+ }
+ }
+ else {
+ priority = ucl_object_get_priority (value) + 1;
}
rspamd_config_add_symbol (cfg, cur_item->symbol,
diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c
index 0fe0a23ad..db9a8d604 100644
--- a/src/rspamadm/configtest.c
+++ b/src/rspamadm/configtest.c
@@ -156,7 +156,7 @@ rspamadm_configtest (gint argc, gchar **argv, const struct rspamadm_command *cmd
ret = rspamd_config_post_load (cfg, RSPAMD_CONFIG_INIT_SYMCACHE);
}
- if (!rspamd_symcache_validate (rspamd_main->cfg->cache,
+ if (ret && !rspamd_symcache_validate (rspamd_main->cfg->cache,
rspamd_main->cfg,
FALSE)) {
ret = FALSE;