From: Aki Tuomi Date: Mon, 28 Nov 2016 21:05:16 +0000 (+0200) Subject: mail-crypt: Do not attempt to cache keys on failure X-Git-Tag: 2.2.27~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55f91814d888bd9f4439a01a913a81598851a036;p=thirdparty%2Fdovecot%2Fcore.git mail-crypt: Do not attempt to cache keys on failure --- diff --git a/src/plugins/mail-crypt/mail-crypt-key.c b/src/plugins/mail-crypt/mail-crypt-key.c index c104428fca..76b92a9174 100644 --- a/src/plugins/mail-crypt/mail-crypt-key.c +++ b/src/plugins/mail-crypt/mail-crypt-key.c @@ -1063,14 +1063,12 @@ int mail_crypt_box_generate_keypair(struct mailbox *box, ret = 0; - if (mail_crypt_generate_keypair(curve, pair, pubid_r, error_r) < 0) - ret = -1; - if (ret == 0 && - mail_crypt_box_set_keys(box, *pubid_r, - pair->priv, user_key, pair->pub, - error_r) < 0) { + if ((ret = mail_crypt_generate_keypair(curve, pair, pubid_r, error_r)) < 0) { + /* failed */ + } else if ((ret = mail_crypt_box_set_keys(box, *pubid_r, + pair->priv, user_key, pair->pub, + error_r)) < 0) { dcrypt_keypair_unref(pair); - ret = -1; } else { mail_crypt_put_key_cache(&muser->key_cache, *pubid_r, pair->priv, pair->pub);