aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_rcl.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-20 15:16:40 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-20 15:16:40 +0000
commit4fcb851bbd617d49f17cf689feb0b36c2283fbfe (patch)
tree147c613a2da54c674da82514c709a460f2097244 /src/libserver/cfg_rcl.c
parent8453d28f5a053c268fda79b72b33e1328878f806 (diff)
downloadrspamd-4fcb851bbd617d49f17cf689feb0b36c2283fbfe.tar.gz
rspamd-4fcb851bbd617d49f17cf689feb0b36c2283fbfe.zip
Fix implicit arrays handling in string list parsing.
Diffstat (limited to 'src/libserver/cfg_rcl.c')
-rw-r--r--src/libserver/cfg_rcl.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 21dff7dd1..69d11f756 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1879,44 +1879,37 @@ rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg,
target = (GList **)(((gchar *)pd->user_struct) + pd->offset);
- if (obj->type == UCL_STRING) {
- /* Just a single string */
- val = rspamd_mempool_strdup (cfg->cfg_pool,
- ucl_copy_value_trash (obj));
- *target = g_list_prepend (*target, val);
- }
- else if (obj->type == UCL_ARRAY) {
-
- while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) {
- switch (cur->type) {
- case UCL_STRING:
- val =
- rspamd_mempool_strdup (cfg->cfg_pool,
- ucl_copy_value_trash (cur));
- break;
- case UCL_INT:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%L", cur->value.iv);
- break;
- case UCL_FLOAT:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%f", cur->value.dv);
- break;
- case UCL_BOOLEAN:
- val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%b", (gboolean)cur->value.iv);
- break;
- default:
- g_set_error (err,
- CFG_RCL_ERROR,
- EINVAL,
- "cannot convert an object or array to string");
- return FALSE;
- }
- *target = g_list_prepend (*target, val);
+ iter = ucl_object_iterate_new (obj);
+
+ while ((cur = ucl_object_iterate_safe (iter, true)) != NULL) {
+ switch (cur->type) {
+ case UCL_STRING:
+ val = rspamd_mempool_strdup (cfg->cfg_pool,
+ ucl_copy_value_trash (cur));
+ break;
+ case UCL_INT:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%L", cur->value.iv);
+ break;
+ case UCL_FLOAT:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%f", cur->value.dv);
+ break;
+ case UCL_BOOLEAN:
+ val = rspamd_mempool_alloc (cfg->cfg_pool, num_str_len);
+ rspamd_snprintf (val, num_str_len, "%b", (gboolean)cur->value.iv);
+ break;
+ default:
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot convert an object or array to string");
+ return FALSE;
}
+ *target = g_list_prepend (*target, val);
}
- else {
+
+ if (*target == NULL) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,