From: Timo Sirainen Date: Thu, 8 Jun 2017 17:24:26 +0000 (+0300) Subject: imap-quota: If quota root doesn't have any quotas, don't send empty QUOTA reply X-Git-Tag: 2.3.0.rc1~1444 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f162f350e1eacce12288a565657e769d7976dd7f;p=thirdparty%2Fdovecot%2Fcore.git imap-quota: If quota root doesn't have any quotas, don't send empty QUOTA reply For example if GETQUOTA is asked for fs quota, but the user doesn't have fs quota enabled. --- diff --git a/src/plugins/imap-quota/imap-quota-plugin.c b/src/plugins/imap-quota/imap-quota-plugin.c index dab7c2877f..feebbadc5f 100644 --- a/src/plugins/imap-quota/imap-quota-plugin.c +++ b/src/plugins/imap-quota/imap-quota-plugin.c @@ -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)