]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event-filter - Use p_strdup() instead of p_strdup_empty() to avoid NULLs
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Tue, 12 Jan 2021 16:15:44 +0000 (11:15 -0500)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Thu, 21 Jan 2021 14:41:28 +0000 (14:41 +0000)
The code used p_strdup_empty() in an (incorrect) attempt to avoid NULLs
turning into empty strings ("").  None of the strdup variants do this.
However, p_strdup_empty() converts empty strings to NULLs.  This caused a
NULL pointer dereference later on.

src/lib/event-filter-parser.y
src/lib/event-filter.c

index a1e4347480ae9fb738fe2d0878534e509aacc1b8..c3db39d428f3317f2010ce7300db7dc84dbabd24 100644 (file)
@@ -74,7 +74,7 @@ static struct event_filter_node *key_value(struct event_filter_parser_state *sta
                                file = p_strdup_until(state->pool, b, colon);
                        }
                } else {
-                       file = p_strdup_empty(state->pool, b);
+                       file = p_strdup(state->pool, b);
                        line = 0;
                }
 
index 4db4584b1dfb48448abb187dbe16784506a15e54..37395061946a2a1a17c8cb2ff80a9eac09d44883 100644 (file)
@@ -277,7 +277,7 @@ void event_filter_add(struct event_filter *filter,
                node = p_new(filter->pool, struct event_filter_node, 1);
                node->type = EVENT_FILTER_NODE_TYPE_EVENT_SOURCE_LOCATION;
                node->op = EVENT_FILTER_OP_CMP_EQ;
-               node->str = p_strdup_empty(filter->pool, query->source_filename);
+               node->str = p_strdup(filter->pool, query->source_filename);
                node->intmax = query->source_linenum;
 
                add_node(filter->pool, &int_query->expr, node);
@@ -300,14 +300,14 @@ clone_expr(pool_t pool, struct event_filter_node *old)
        new->op = old->op;
        new->children[0] = clone_expr(pool, old->children[0]);
        new->children[1] = clone_expr(pool, old->children[1]);
-       new->str = p_strdup_empty(pool, old->str);
+       new->str = p_strdup(pool, old->str);
        new->intmax = old->intmax;
        new->category.log_type = old->category.log_type;
-       new->category.name = p_strdup_empty(pool, old->category.name);
+       new->category.name = p_strdup(pool, old->category.name);
        new->category.ptr = old->category.ptr;
-       new->field.key = p_strdup_empty(pool, old->field.key);
+       new->field.key = p_strdup(pool, old->field.key);
        new->field.value_type = old->field.value_type;
-       new->field.value.str = p_strdup_empty(pool, old->field.value.str);
+       new->field.value.str = p_strdup(pool, old->field.value.str);
        new->field.value.intmax = old->field.value.intmax;
        new->field.value.timeval = old->field.value.timeval;