]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-quota: If quota root doesn't have any quotas, don't send empty QUOTA reply
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 8 Jun 2017 17:24:26 +0000 (20:24 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 13 Jun 2017 09:06:41 +0000 (12:06 +0300)
For example if GETQUOTA is asked for fs quota, but the user doesn't have fs
quota enabled.

src/plugins/imap-quota/imap-quota-plugin.c

index dab7c2877fc59c6e620de9df38115f1796b33eef..feebbadc5ff72ee80af19525d94e0c67d0471aca 100644 (file)
@@ -38,6 +38,7 @@ quota_reply_write(string_t *str, struct mail_user *user,
         const char *name, *const *list;
        unsigned int i;
        uint64_t value, limit;
+       size_t prefix_len, orig_len = str_len(str);
        int ret = 0;
 
        str_append(str, "* QUOTA ");
@@ -45,6 +46,7 @@ quota_reply_write(string_t *str, struct mail_user *user,
        imap_append_astring(str, name);
 
        str_append(str, " (");
+       prefix_len = str_len(str);
        list = quota_root_get_resources(root);
        for (i = 0; *list != NULL; list++) {
                ret = quota_get_resource(root, "", *list, &value, &limit);
@@ -59,6 +61,11 @@ quota_reply_write(string_t *str, struct mail_user *user,
                        i++;
                }
        }
+       if (ret == 0 && str_len(str) == prefix_len) {
+               /* this quota root doesn't have any quota actually enabled. */
+               str_truncate(str, orig_len);
+               return;
+       }
        str_append(str, ")\r\n");
 
        if (ret < 0)