]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fixed iterating attribute prefix that matched the attribute itself.
authorTimo Sirainen <tss@iki.fi>
Fri, 11 Sep 2015 11:02:01 +0000 (14:02 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 11 Sep 2015 11:02:01 +0000 (14:02 +0300)
So if attribute key was "foo", iterating "foo" returned garbage because it
skipped over the trailing \0.

src/lib-storage/mailbox-attribute.c

index 41e331b467e42fdaefc381677d0e34c89705f23e..9cefaac46220a02b3bc16b3da6bf0630d28ef4a4 100644 (file)
@@ -131,10 +131,17 @@ mailbox_internal_attributes_get(enum mail_attribute_type type,
                if (plen > 0) {
                        if (strncmp(key, bare_prefix, plen) != 0)
                                return;
-                       if (key[plen] != '/' && strlen(key) != plen)
+                       if (key[plen] == '/') {
+                               /* remove prefix */
+                               key += plen + 1;
+                       } else if (key[plen] == '\0') {
+                               /* list the key itself, so this becomes an
+                                  empty key string. it's the same as how the
+                                  dict backend works too. */
+                               key += plen;
+                       } else {
                                return;
-                       /* remove prefix */
-                       key += plen + 1;
+                       }
                }
                if (have_dict || regs[i].rank == MAIL_ATTRIBUTE_INTERNAL_RANK_AUTHORITY)
                        array_append(attrs, &key, 1);