[dovecot-cvs] dovecot: Give an error if quota rule is missing ':'.

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 12 18:39:53 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/96b796e46d0e
changeset: 5703:96b796e46d0e
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 12 18:39:49 2007 +0300
description:
Give an error if quota rule is missing ':'.

diffstat:

1 file changed, 13 insertions(+), 12 deletions(-)
src/plugins/quota/quota.c |   25 +++++++++++++------------

diffs (46 lines):

diff -r 3c3159eb7175 -r 96b796e46d0e src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Jun 12 18:36:31 2007 +0300
+++ b/src/plugins/quota/quota.c	Tue Jun 12 18:39:49 2007 +0300
@@ -175,29 +175,30 @@ int quota_root_add_rule(struct quota_roo
 			const char **error_r)
 {
 	struct quota_rule *rule;
-	const char **args;
+	const char *p, *mailbox_name, **args;
 	int ret = 0;
 
-	if (*rule_def == '\0') {
-		*error_r = "Empty rule";
+	p = strchr(rule_def, ':');
+	if (p == NULL) {
+		*error_r = "Invalid rule";
 		return -1;
 	}
 
 	/* <mailbox name>:<quota limits> */
 	t_push();
-        args = t_strsplit(rule_def, ":");
-
-	rule = quota_root_rule_find(root, *args);
+	mailbox_name = t_strdup_until(rule_def, p++);
+
+	rule = quota_root_rule_find(root, mailbox_name);
 	if (rule == NULL) {
-		if (strcmp(*args, RULE_NAME_ALL_MAILBOXES) == 0)
+		if (strcmp(mailbox_name, RULE_NAME_ALL_MAILBOXES) == 0)
 			rule = &root->default_rule;
 		else {
 			rule = array_append_space(&root->rules);
-			rule->mailbox_name = p_strdup(root->pool, *args);
-		}
-	}
-
-	for (args++; *args != NULL; args++) {
+			rule->mailbox_name = p_strdup(root->pool, mailbox_name);
+		}
+	}
+
+	for (args = t_strsplit(p, ":"); *args != NULL; args++) {
 		if (strncmp(*args, "storage=", 8) == 0)
 			rule->bytes_limit = strtoll(*args + 8, NULL, 10) * 1024;
 		else if (strncmp(*args, "bytes=", 6) == 0)


More information about the dovecot-cvs mailing list