Skip to content

Commit

Permalink
imap-quota: If quota root doesn't have any quotas, don't send empty Q…
Browse files Browse the repository at this point in the history
…UOTA reply

For example if GETQUOTA is asked for fs quota, but the user doesn't have fs
quota enabled.
  • Loading branch information
sirainen authored and villesavolainen committed Jun 13, 2017
1 parent 81d10af commit 27456d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/plugins/imap-quota/imap-quota-plugin.c
Expand Up @@ -38,13 +38,15 @@ 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 ");
name = imap_quota_root_get_name(user, owner, root);
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);
Expand All @@ -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)
Expand Down

0 comments on commit 27456d2

Please sign in to comment.