]> granicus.if.org Git - neomutt/commitdiff
Fix pgp and smime decryption in mutt_prepare_template().
authorKevin McCarthy <kevin@8t8.us>
Sun, 7 Feb 2016 18:15:27 +0000 (10:15 -0800)
committerKevin McCarthy <kevin@8t8.us>
Sun, 7 Feb 2016 18:15:27 +0000 (10:15 -0800)
Change the "combined" multipart decryption block to only work for pgp,
since mutt_is_multipart_encrypted() currently only checks for pgp
headers and it therefore only worked for pgp in the first place.

Fix the newhdr->security to be based on what that function returns,
instead of the "context" hdr passed in.

Add a smime decryption block below when iterating through the content.

Fix the application/pgp decryption block to assign to hdr->security
using the type of the app/pgp part instead of hdr->content.

postpone.c

index d6eb83c25632171ba089079483abe7fb9b1388a1..cec150fd7d86f2ad572e0b572ede25c0dbf0c660 100644 (file)
@@ -541,9 +541,9 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
   char file[_POSIX_PATH_MAX];
   BODY *b;
   FILE *bfp;
-
   int rv = -1;
   STATE s;
+  int sec_type;
 
   memset (&s, 0, sizeof (s));
 
@@ -574,17 +574,15 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
 
   /* decrypt pgp/mime encoded messages */
 
-  if ((WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security)
-      && mutt_is_multipart_encrypted (newhdr->content))
+  if ((WithCrypto & APPLICATION_PGP) &&
+      (sec_type = mutt_is_multipart_encrypted (newhdr->content)))
   {
-    int ccap = WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security;
-    newhdr->security |= ENCRYPT | ccap;
-    if (!crypt_valid_passphrase (ccap))
+    newhdr->security |= sec_type;
+    if (!crypt_valid_passphrase (sec_type))
       goto err;
 
     mutt_message _("Decrypting message...");
-    if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
-       || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
+    if ((crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
        || b == NULL)
     {
  err:
@@ -678,18 +676,26 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
       goto bail;
 
 
-    if ((WithCrypto & APPLICATION_PGP)
-       && (mutt_is_application_pgp (b) & (ENCRYPT|SIGN)))
+    if ((WithCrypto & APPLICATION_PGP) &&
+       ((sec_type = mutt_is_application_pgp (b)) & (ENCRYPT|SIGN)))
     {
-
       mutt_body_handler (b, &s);
 
-      newhdr->security |= mutt_is_application_pgp (newhdr->content);
+      newhdr->security |= sec_type;
 
       b->type = TYPETEXT;
       mutt_str_replace (&b->subtype, "plain");
       mutt_delete_parameter ("x-action", &b->parameter);
     }
+    else if ((WithCrypto & APPLICATION_SMIME) &&
+             ((sec_type = mutt_is_application_smime (b)) & (ENCRYPT|SIGN)))
+    {
+      mutt_body_handler (b, &s);
+
+      newhdr->security |= sec_type;
+      b->type = TYPETEXT;
+      mutt_str_replace (&b->subtype, "plain");
+    }
     else
       mutt_decode_attachment (b, &s);