File mutt-1.8.2-from4crypt.diff of Package mutt

From 67061b07d357086d1a0526a3c53adfa32f72929f Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Subject: Fix crash if no from is set or found

On multi folder mailbox setup and without a set
'From:' line in ~/.muttrc the mutt crash with SIGSEGV
on a NULL pointer at msg->env->from

Signed-off-by: Werner Fink <werner@suse.de>
---
 crypt.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/crypt.c
+++ b/crypt.c	2017-05-10 09:02:42.654128156 +0000
@@ -179,12 +179,22 @@ int mutt_protect(HEADER *msg, char *keyl
 
   if (option(OPTCRYPTUSEPKA) && (msg->security & SIGN))
   {
+    const char *mailbox;
+    ADDRESS *from = msg->env->from;
+
+    if (!from)
+      from = mutt_default_from();
+
+    mailbox = from->mailbox;
+    if (!mailbox && EnvFrom)
+      mailbox = EnvFrom->mailbox;
+
     /* Set sender (necessary for e.g. PKA).  */
 
     if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
-      crypt_smime_set_sender(msg->env->from->mailbox);
+      crypt_smime_set_sender(mailbox);
     else if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
-      crypt_pgp_set_sender(msg->env->from->mailbox);
+      crypt_pgp_set_sender(mailbox);
   }
 
   if (msg->security & SIGN)
openSUSE Build Service is sponsored by