aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2025-06-04 12:17:04 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2025-06-04 12:17:04 +0100
commitdb7496bdc917e72ff3bf3ec25fc9d665e2da5abf (patch)
tree0d0bd625c89c93518be8322de6853af4ed510b22
parent8e1234de91e000a2e6518220d7b83d7d93ba097a (diff)
downloadrspamd-vstakhov-ucl-fix.tar.gz
rspamd-vstakhov-ucl-fix.zip
[Fix] Backport some issues from libuclvstakhov-ucl-fix
-rw-r--r--contrib/libucl/ucl_parser.c10
-rw-r--r--contrib/libucl/ucl_util.c32
2 files changed, 38 insertions, 4 deletions
diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c
index 6be16d121..e56a010ff 100644
--- a/contrib/libucl/ucl_parser.c
+++ b/contrib/libucl/ucl_parser.c
@@ -1246,10 +1246,12 @@ ucl_parser_process_object_element (struct ucl_parser *parser, ucl_object_t *nobj
container = parser->stack->obj->value.ov;
DL_FOREACH (parser->stack->obj, cur) {
- tobj = __DECONST (ucl_object_t *, ucl_hash_search_obj (cur->value.ov, nobj));
+ if (cur->type == UCL_OBJECT) {
+ tobj = __DECONST (ucl_object_t *, ucl_hash_search_obj (cur->value.ov, nobj));
- if (tobj != NULL) {
- break;
+ if (tobj != NULL) {
+ break;
+ }
}
}
@@ -3165,7 +3167,7 @@ ucl_parser_add_string (struct ucl_parser *parser, const char *data,
bool
ucl_set_include_path (struct ucl_parser *parser, ucl_object_t *paths)
{
- if (parser == NULL || paths == NULL) {
+ if (parser == NULL || paths == NULL || paths->type != UCL_ARRAY) {
return false;
}
diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c
index b00f2779e..d5b84f6a5 100644
--- a/contrib/libucl/ucl_util.c
+++ b/contrib/libucl/ucl_util.c
@@ -3148,6 +3148,10 @@ ucl_object_frombool (bool bv)
bool
ucl_array_append (ucl_object_t *top, ucl_object_t *elt)
{
+ if (top->type != UCL_ARRAY) {
+ return false;
+ }
+
UCL_ARRAY_GET (vec, top);
if (elt == NULL || top == NULL) {
@@ -3177,6 +3181,10 @@ e0:
bool
ucl_array_prepend (ucl_object_t *top, ucl_object_t *elt)
{
+ if (top->type != UCL_ARRAY) {
+ return false;
+ }
+
UCL_ARRAY_GET (vec, top);
if (elt == NULL || top == NULL) {
@@ -3242,6 +3250,10 @@ e0:
ucl_object_t *
ucl_array_delete (ucl_object_t *top, ucl_object_t *elt)
{
+ if (top->type != UCL_ARRAY) {
+ return NULL;
+ }
+
UCL_ARRAY_GET (vec, top);
ucl_object_t *ret = NULL;
unsigned i;
@@ -3290,6 +3302,10 @@ ucl_array_tail (const ucl_object_t *top)
ucl_object_t *
ucl_array_pop_last (ucl_object_t *top)
{
+ if (top->type != UCL_ARRAY) {
+ return NULL;
+ }
+
UCL_ARRAY_GET (vec, top);
ucl_object_t **obj, *ret = NULL;
@@ -3306,6 +3322,10 @@ ucl_array_pop_last (ucl_object_t *top)
ucl_object_t *
ucl_array_pop_first (ucl_object_t *top)
{
+ if (top->type != UCL_ARRAY) {
+ return NULL;
+ }
+
UCL_ARRAY_GET (vec, top);
ucl_object_t **obj, *ret = NULL;
@@ -3338,6 +3358,10 @@ ucl_array_size (const ucl_object_t *top)
const ucl_object_t *
ucl_array_find_index (const ucl_object_t *top, unsigned int index)
{
+ if (top->type != UCL_ARRAY) {
+ return NULL;
+ }
+
UCL_ARRAY_GET (vec, top);
if (vec != NULL && vec->n > 0 && index < vec->n) {
@@ -3350,6 +3374,10 @@ ucl_array_find_index (const ucl_object_t *top, unsigned int index)
unsigned int
ucl_array_index_of (ucl_object_t *top, ucl_object_t *elt)
{
+ if (top->type != UCL_ARRAY) {
+ return (unsigned int)(-1);
+ }
+
UCL_ARRAY_GET (vec, top);
unsigned i;
@@ -3370,6 +3398,10 @@ ucl_object_t *
ucl_array_replace_index (ucl_object_t *top, ucl_object_t *elt,
unsigned int index)
{
+ if (top->type != UCL_ARRAY) {
+ return NULL;
+ }
+
UCL_ARRAY_GET (vec, top);
ucl_object_t *ret = NULL;