From: Timo Sirainen Date: Fri, 11 Sep 2015 11:02:01 +0000 (+0300) Subject: lib-storage: Fixed iterating attribute prefix that matched the attribute itself. X-Git-Tag: 2.2.19.rc1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42f2d982a0f2f883fc0e84f204e12cda5f5ef768;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fixed iterating attribute prefix that matched the attribute itself. So if attribute key was "foo", iterating "foo" returned garbage because it skipped over the trailing \0. --- diff --git a/src/lib-storage/mailbox-attribute.c b/src/lib-storage/mailbox-attribute.c index 41e331b467..9cefaac462 100644 --- a/src/lib-storage/mailbox-attribute.c +++ b/src/lib-storage/mailbox-attribute.c @@ -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);