From d1cf3325f5ffb2b767c724d524f49c94958c66cb Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Wed, 13 May 2015 19:52:51 +0200
Subject: [PATCH] managesieve: Storage quota was not always enforced properly
 for scripts uploaded as quoted string. Nobody does that, but we support it.

---
 src/managesieve/cmd-putscript.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/managesieve/cmd-putscript.c b/src/managesieve/cmd-putscript.c
index a7c3230d6..0c782d88f 100644
--- a/src/managesieve/cmd-putscript.c
+++ b/src/managesieve/cmd-putscript.c
@@ -183,6 +183,11 @@ static bool cmd_putscript_finish_parsing(struct client_command_context *cmd)
 
 		/* If quoted string, the size was not known until now */
 		if ( ctx->script_size == 0 ) {
+			if (sieve_script_get_size(script, &ctx->script_size) < 0) {
+				client_send_storage_error(client, ctx->storage);
+				cmd_putscript_finish(ctx);
+				return TRUE;
+			}
 			/* Check quota; max size is already checked */
 			if ( ctx->scriptname != NULL && !managesieve_quota_check_all
 					(client, ctx->scriptname, ctx->script_size) ) {
-- 
GitLab