From 2453834bce8ac340695f990d7bff617404c28af2 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 12 Jun 2018 16:56:51 +0300 Subject: [PATCH] mail-crypt: Fix memory leak in "doveadm mailbox cryptokey generate" --- src/plugins/mail-crypt/doveadm-mail-crypt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/mail-crypt/doveadm-mail-crypt.c b/src/plugins/mail-crypt/doveadm-mail-crypt.c index 612f469ba9..e7a83d8bc7 100644 --- a/src/plugins/mail-crypt/doveadm-mail-crypt.c +++ b/src/plugins/mail-crypt/doveadm-mail-crypt.c @@ -342,6 +342,7 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, key_id, &error)) { i_error("dcrypt_key_id_public() failed: %s", error); + dcrypt_key_unref_public(&user_key); return -1; } const char *hash = binary_to_hex(key_id->data, @@ -351,6 +352,7 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, res->id = p_strdup(_ctx->pool, hash); res->success = TRUE; ctx->matched_keys++; + dcrypt_key_unref_public(&user_key); return 1; } struct dcrypt_keypair pair; @@ -371,8 +373,10 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, ctx->matched_keys++; } - if (ctx->userkey_only) + if (ctx->userkey_only) { + dcrypt_key_unref_public(&user_key); return 0; + } const char *const *patterns = (const char *const[]){ "*", NULL }; -- 2.47.3