diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-10 12:36:12 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-10 12:36:12 +0000 |
commit | fe3edc0dfa04158efee4fa935ab2640095265063 (patch) | |
tree | 14f0fe99c718a321e71724030a53e289eec790a2 /src/libserver/dynamic_cfg.c | |
parent | cb846eabcdd306de3ff54c77ad0184f08850dead (diff) | |
download | rspamd-fe3edc0dfa04158efee4fa935ab2640095265063.tar.gz rspamd-fe3edc0dfa04158efee4fa935ab2640095265063.zip |
[Fix] Fix usage of unsafe ucl iterators
Diffstat (limited to 'src/libserver/dynamic_cfg.c')
-rw-r--r-- | src/libserver/dynamic_cfg.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c index b74b0a8f9..6e319ed36 100644 --- a/src/libserver/dynamic_cfg.c +++ b/src/libserver/dynamic_cfg.c @@ -346,16 +346,22 @@ dynamic_metric_find_elt (const ucl_object_t *arr, const gchar *name) ucl_object_iter_t it = NULL; const ucl_object_t *cur, *n; - while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) { + it = ucl_object_iterate_new (arr); + + while ((cur = ucl_object_iterate_safe (it, true)) != NULL) { if (cur->type == UCL_OBJECT) { n = ucl_object_lookup (cur, "name"); if (n && n->type == UCL_STRING && strcmp (name, ucl_object_tostring (n)) == 0) { + ucl_object_iterate_free (it); + return (ucl_object_t *)ucl_object_lookup (cur, "value"); } } } + ucl_object_iterate_free (it); + return NULL; } @@ -365,16 +371,22 @@ dynamic_metric_find_metric (const ucl_object_t *arr, const gchar *metric) ucl_object_iter_t it = NULL; const ucl_object_t *cur, *n; - while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) { + it = ucl_object_iterate_new (arr); + + while ((cur = ucl_object_iterate_safe (it, true)) != NULL) { if (cur->type == UCL_OBJECT) { n = ucl_object_lookup (cur, "metric"); if (n && n->type == UCL_STRING && strcmp (metric, ucl_object_tostring (n)) == 0) { + ucl_object_iterate_free (it); + return (ucl_object_t *)cur; } } } + ucl_object_iterate_free (it); + return NULL; } |