]> granicus.if.org Git - neomutt/commitdiff
Add missing setup calls when resuming encrypted drafts.
authorKevin McCarthy <kevin@8t8.us>
Thu, 11 Jan 2018 23:08:30 +0000 (15:08 -0800)
committerRichard Russon <rich@flatcap.org>
Sat, 13 Jan 2018 13:59:03 +0000 (13:59 +0000)
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.

postpone.c

index 429541c8bc3a82b2ec66cf599c49814da7dd9c25..d7251327695fa56b94090e95935a2994baa83e59 100644 (file)
@@ -580,17 +580,12 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr,
   {
     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_env_free(&newhdr->env);
-      mutt_free_body(&newhdr->content);
-      mutt_error(_("Decryption failed."));
-      return -1;
+      goto bail;
     }
 
     mutt_free_body(&newhdr->content);
@@ -678,7 +673,18 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr,
     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;
 
@@ -689,7 +695,19 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr,
     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;