]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Match multiple names in local_name
authorJ. Nick Koston <nick@cpanel.net>
Thu, 1 Dec 2016 07:38:02 +0000 (01:38 -0600)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 3 Dec 2016 16:45:02 +0000 (18:45 +0200)
This can significantly reduce memory usage when using
a UCC certificate with multiple names by only loading
the certificate and key once.

src/config/config-filter.c

index 426a32639a65262764cb8007d3ad9f000284e8cb..4c2071a2c87404517779a6c7ed4ce103b9960ff2 100644 (file)
@@ -37,7 +37,17 @@ static bool config_filter_match_rest(const struct config_filter *mask,
        if (mask->local_name != NULL) {
                if (filter->local_name == NULL)
                        return FALSE;
-               if (dns_match_wildcard(filter->local_name, mask->local_name) != 0)
+               /* Handle multiple names seperated by spaces in local_name
+                * Ex: local_name "mail.domain.tld domain.tld mx.domain.tld" { ... } */
+               const char *const *local_name = t_strsplit_spaces(mask->local_name, " ");
+               bool matched = FALSE;
+               for (; *local_name != NULL; local_name++) {
+                       if (dns_match_wildcard(filter->local_name, *local_name) == 0) {
+                               matched = TRUE;
+                               break;
+                       }
+               }
+               if (!matched)
                        return FALSE;
        }
        /* FIXME: it's not comparing full masks */