-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
it = ucl_object_iterate_new(cur_elt);
while ((cur = ucl_object_iterate_safe(it, true)) != NULL) {
- str = ucl_object_tostring(cur);
- if (!*target) {
- *target = rspamd_map_helper_new_radix(
- rspamd_map_add_fake(cfg, description, map_name));
- }
- rspamd_map_helper_insert_radix_resolve(*target, str, "");
+ if (ucl_object_type(cur) == UCL_STRING) {
+ str = ucl_object_tostring(cur);
+ if (!*target) {
+ *target = rspamd_map_helper_new_radix(
+ rspamd_map_add_fake(cfg, description, map_name));
+ }
+
+ rspamd_map_helper_insert_radix_resolve(*target, str, "");
+ }
+ else {
+ g_set_error(err,
+ g_quark_from_static_string("rspamd-config"),
+ EINVAL, "bad element inside array object for %s: expected string, got: %s",
+ ucl_object_key(obj), ucl_object_type_to_string(ucl_object_type(cur)));
+ ucl_object_iterate_free(it);
+ return FALSE;
+ }
}
ucl_object_iterate_free(it);
if (ctx != NULL) {
if (cfg->local_addrs) {
- rspamd_config_radix_from_ucl(cfg, cfg->local_addrs,
- "Local addresses",
- (struct rspamd_radix_map_helper **) ctx->local_addrs,
- NULL,
- NULL, "local addresses");
+ ret = rspamd_config_radix_from_ucl(cfg, cfg->local_addrs,
+ "Local addresses",
+ (struct rspamd_radix_map_helper **) ctx->local_addrs,
+ NULL,
+ NULL, "local addresses");
}
rspamd_free_zstd_dictionary(ctx->in_dict);
-/*-
- * Copyright 2018 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
struct rspamd_map *map;
map = r->map;
+
+ if (!key) {
+ msg_warn_map("cannot insert NULL value in the map: %s",
+ map->name);
+ return;
+ }
+
tok.begin = key;
tok.len = strlen(key);