]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
layout=fs: Fixed checking if pattern was valid with hierarchy separator wasn't the...
authorTimo Sirainen <tss@iki.fi>
Sun, 11 Jul 2010 18:42:48 +0000 (19:42 +0100)
committerTimo Sirainen <tss@iki.fi>
Sun, 11 Jul 2010 18:42:48 +0000 (19:42 +0100)
For example if separator was ';', which the code internally converted to '/',
it would have been possible to try to list e.g. ";*", which could have been
translated to "/*". Luckily this wasn't actually working, but it could have
caused other broken replies and possibly some problems with ACL plugin.

src/lib-storage/list/mailbox-list-fs-iter.c

index 1ca56b76647d6dee2a87f2cc28adcb3c863daed7..e87867fefeb7a3c34e3ad50f85213d76aeed2866 100644 (file)
@@ -212,7 +212,7 @@ fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
                  enum mailbox_list_iter_flags flags)
 {
        struct fs_list_iterate_context *ctx;
-       const char *path, *vpath, *rootdir, *test_pattern;
+       const char *path, *vpath, *rootdir, *test_pattern, *real_pattern;
        char *pattern;
        DIR *dirp;
        unsigned int prefix_len;
@@ -236,7 +236,11 @@ fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
                   validation. */
                if (strncmp(test_pattern, _list->ns->prefix, prefix_len) == 0)
                        test_pattern += prefix_len;
-               if (mailbox_list_is_valid_pattern(_list, test_pattern)) {
+               /* check pattern also when it's converted to use real
+                  separators. */
+               real_pattern = mail_namespace_fix_sep(_list->ns, test_pattern);
+               if (mailbox_list_is_valid_pattern(_list, test_pattern) &&
+                   mailbox_list_is_valid_pattern(_list, real_pattern)) {
                        if (strcasecmp(*patterns, "INBOX") == 0) {
                                ctx->inbox_match = TRUE;
                                continue;