]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Fix matching parent categories in event filter
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 31 Aug 2018 10:04:53 +0000 (13:04 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 13 Nov 2018 13:29:41 +0000 (15:29 +0200)
So far this hasn't caused problems, because parent events had been using
parent categories. However, if the parent category wasn't used by an event
or its parents, an event filter wouldn't have matched it.

src/lib/event-filter.c

index 37aa3465b8575d03bb43d26e12de9b1ed82483e4..b98692a60fc07c8a5ce9670fe56e66c0d1d58ea0 100644 (file)
@@ -400,6 +400,17 @@ bool event_filter_import_unescaped(struct event_filter *filter,
        return TRUE;
 }
 
+static bool
+event_category_match(const struct event_category *category,
+                    const struct event_category *wanted_category)
+{
+       for (; category != NULL; category = category->parent) {
+               if (category == wanted_category)
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 static bool
 event_has_category(struct event *event, struct event_category *wanted_category)
 {
@@ -410,7 +421,7 @@ event_has_category(struct event *event, struct event_category *wanted_category)
        while (event != NULL) {
                if (array_is_created(&event->categories)) {
                        array_foreach(&event->categories, catp) {
-                               if (*catp == wanted_category)
+                               if (event_category_match(*catp, wanted_category))
                                        return TRUE;
                        }
                }