From: Kevin McCarthy Date: Thu, 11 Jan 2018 23:08:30 +0000 (-0800) Subject: Add missing setup calls when resuming encrypted drafts. X-Git-Tag: mutt-1-9-3-rel~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=667a4710e56a89107a690cd1b914ca7e7377d515;p=mutt Add missing setup calls when resuming encrypted drafts. Calls to get the passphrase were missing for app/pgp and app/smime. App/smime was also missing a call to crypt_smime_getkeys(). If a failure occurs, report it back, rather than just continuing. Otherwise, postponed messages could be completely lost. --- diff --git a/postpone.c b/postpone.c index e28a8759..56e176bd 100644 --- a/postpone.c +++ b/postpone.c @@ -592,18 +592,14 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, { newhdr->security |= sec_type; if (!crypt_valid_passphrase (sec_type)) - goto err; + goto bail; mutt_message _("Decrypting message..."); if ((crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) || b == NULL) { - err: - mx_close_message (ctx, &msg); - mutt_free_envelope (&newhdr->env); - mutt_free_body (&newhdr->content); mutt_error _("Decryption failed."); - return -1; + goto bail; } mutt_free_body (&newhdr->content); @@ -692,7 +688,18 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, if ((WithCrypto & APPLICATION_PGP) && ((sec_type = mutt_is_application_pgp (b)) & (ENCRYPT|SIGN))) { - mutt_body_handler (b, &s); + if (sec_type & ENCRYPT) + { + if (!crypt_valid_passphrase (APPLICATION_PGP)) + goto bail; + mutt_message _("Decrypting message..."); + } + + if (mutt_body_handler (b, &s) < 0) + { + mutt_error _("Decryption failed."); + goto bail; + } newhdr->security |= sec_type; @@ -703,7 +710,19 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, else if ((WithCrypto & APPLICATION_SMIME) && ((sec_type = mutt_is_application_smime (b)) & (ENCRYPT|SIGN))) { - mutt_body_handler (b, &s); + if (sec_type & ENCRYPT) + { + if (!crypt_valid_passphrase (APPLICATION_SMIME)) + goto bail; + crypt_smime_getkeys (newhdr->env); + mutt_message _("Decrypting message..."); + } + + if (mutt_body_handler (b, &s) < 0) + { + mutt_error _("Decryption failed."); + goto bail; + } newhdr->security |= sec_type; b->type = TYPETEXT;