diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-18 18:30:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-18 18:30:08 +0100 |
commit | f789d85b3a4b239a2a22a984eb6f403fd298dcbf (patch) | |
tree | e8eb5805222a6c54d4470d16b20289d349f60c2b /contrib/libucl/ucl_util.c | |
parent | 82c33aae8f42712a21d845608142efcb2f6ae3bd (diff) | |
download | rspamd-f789d85b3a4b239a2a22a984eb6f403fd298dcbf.tar.gz rspamd-f789d85b3a4b239a2a22a984eb6f403fd298dcbf.zip |
[Fix] Backport fix for empty files inclusion from libucl
Issue: #596
Reported by: @assistcontrol
Diffstat (limited to 'contrib/libucl/ucl_util.c')
-rw-r--r-- | contrib/libucl/ucl_util.c | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index 6376d6a42..1adb8c3b6 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -975,6 +975,7 @@ ucl_include_file_single (const unsigned char *data, size_t len, if (params->soft_fail) { return false; } + return (!params->must_exist || false); } @@ -1172,11 +1173,14 @@ ucl_include_file_single (const unsigned char *data, size_t len, res = ucl_parser_add_chunk_full (parser, buf, buflen, params->priority, params->strat, params->parse_type); - if (!res && !params->must_exist) { - /* Free error */ - utstring_free (parser->err); - parser->err = NULL; - parser->state = UCL_STATE_AFTER_VALUE; + + if (!res) { + if (!params->must_exist) { + /* Free error */ + utstring_free (parser->err); + parser->err = NULL; + res = true; + } } /* Stop nesting the include, take 1 level off the stack */ @@ -3450,3 +3454,39 @@ ucl_comments_find (const ucl_object_t *comments, return NULL; } + +bool +ucl_comments_move (ucl_object_t *comments, + const ucl_object_t *from, const ucl_object_t *to) +{ + const ucl_object_t *found; + ucl_object_t *obj; + + if (comments && from && to) { + found = ucl_object_lookup_len (comments, + (const char *)&from, sizeof (void *)); + + if (found) { + /* Replace key */ + obj = ucl_object_ref (found); + ucl_object_delete_keyl (comments, (const char *)&from, + sizeof (void *)); + ucl_object_insert_key (comments, obj, (const char *)&to, + sizeof (void *), true); + + return true; + } + } + + return false; +} + +void +ucl_comments_add (ucl_object_t *comments, const ucl_object_t *obj, + const char *comment) +{ + if (comments && obj && comment) { + ucl_object_insert_key (comments, ucl_object_fromstring (comment), + (const char *)&obj, sizeof (void *), true); + } +} |