diff --git a/src/managesieve/cmd-havespace.c b/src/managesieve/cmd-havespace.c index e4c344fbde3eb37c3dce26d806f5eae215728dae..50146f2d14185514a8b31e1ba00a85640efb2203 100644 --- a/src/managesieve/cmd-havespace.c +++ b/src/managesieve/cmd-havespace.c @@ -44,7 +44,7 @@ bool cmd_havespace(struct client_command_context *cmd) return TRUE; } - if (!managesieve_quota_check_all(client, scriptname, size)) + if (!managesieve_quota_check_all(cmd, scriptname, size)) return TRUE; client_send_ok(client, "Putscript would succeed."); diff --git a/src/managesieve/cmd-putscript.c b/src/managesieve/cmd-putscript.c index dbe5076404ea34956ee07b28b8066506eab6a543..330b0ad4c87ffd6edf7655f19d2d74fabd535814 100644 --- a/src/managesieve/cmd-putscript.c +++ b/src/managesieve/cmd-putscript.c @@ -231,6 +231,7 @@ cmd_putscript_finish_script(struct cmd_putscript_context *ctx, static void cmd_putscript_handle_script(struct cmd_putscript_context *ctx) { struct client *client = ctx->client; + struct client_command_context *cmd = ctx->cmd; struct sieve_script *script; /* Obtain script object for uploaded script */ @@ -254,7 +255,7 @@ static void cmd_putscript_handle_script(struct cmd_putscript_context *ctx) /* Check quota; max size is already checked */ if (ctx->scriptname != NULL && - !managesieve_quota_check_all(client, ctx->scriptname, + !managesieve_quota_check_all(cmd, ctx->scriptname, ctx->script_size)) { cmd_putscript_finish(ctx); return; @@ -346,11 +347,11 @@ static bool cmd_putscript_continue_parsing(struct client_command_context *cmd) /* Check quota */ if (ctx->scriptname == NULL) { if (!managesieve_quota_check_validsize( - client, ctx->script_size)) + cmd, ctx->script_size)) return cmd_putscript_cancel(ctx, TRUE); } else { if (!managesieve_quota_check_all( - client, ctx->scriptname, ctx->script_size)) + cmd, ctx->scriptname, ctx->script_size)) return cmd_putscript_cancel(ctx, TRUE); } @@ -391,7 +392,7 @@ static bool cmd_putscript_continue_script(struct client_command_context *cmd) if (ctx->max_script_size > 0 && ctx->input->v_offset > ctx->max_script_size) { (void)managesieve_quota_check_validsize( - client, ctx->input->v_offset); + cmd, ctx->input->v_offset); cmd_putscript_finish(ctx); return TRUE; } diff --git a/src/managesieve/managesieve-quota.c b/src/managesieve/managesieve-quota.c index cc0c7be839cda8263fdb7ca8f5dfb9107133642e..aeede4662d421d020eb95510cdba59d172057c8e 100644 --- a/src/managesieve/managesieve-quota.c +++ b/src/managesieve/managesieve-quota.c @@ -15,8 +15,10 @@ uint64_t managesieve_quota_max_script_size(struct client *client) return sieve_storage_quota_max_script_size(client->storage); } -bool managesieve_quota_check_validsize(struct client *client, size_t size) +bool managesieve_quota_check_validsize(struct client_command_context *cmd, + size_t size) { + struct client *client = cmd->client; uint64_t limit; if (!sieve_storage_quota_validsize(client->storage, size, &limit)) { @@ -29,9 +31,10 @@ bool managesieve_quota_check_validsize(struct client *client, size_t size) return TRUE; } -bool managesieve_quota_check_all(struct client *client, +bool managesieve_quota_check_all(struct client_command_context *cmd, const char *scriptname, size_t size) { + struct client *client = cmd->client; enum sieve_storage_quota quota; uint64_t limit; int ret; diff --git a/src/managesieve/managesieve-quota.h b/src/managesieve/managesieve-quota.h index 39a34debeaad6a4c8f7292d604b8edf893a57fa7..f6b37bf639f83f5e7a0166adef84edb143571ae7 100644 --- a/src/managesieve/managesieve-quota.h +++ b/src/managesieve/managesieve-quota.h @@ -3,8 +3,9 @@ uint64_t managesieve_quota_max_script_size(struct client *client); -bool managesieve_quota_check_validsize(struct client *client, size_t size); -bool managesieve_quota_check_all(struct client *client, +bool managesieve_quota_check_validsize(struct client_command_context *cmd, + size_t size); +bool managesieve_quota_check_all(struct client_command_context *cmd, const char *scriptname, size_t size); #endif