This file contains various PGP-related bug-fixes relative
to Mutt 0.89.1i.  Fixed bugs include:

- On the compose menu, adding a PGP public key as the
  5th attachment would lead to a core dump.

- When extracting public keys from attachments, a random
  garbage prefix would be printed in front of every line.

- The PGP 5 invocation code contained several typographic
  errors.

- When displaying a singed (but not encrypted) message's
  attachments, mutt would ask you for your pass phrase.

- When referencing PGP 5 subkeys, the corresponding "main"
  key's ID is now used.  This seems to be the correct
  behaviour.

Most of these patches are contained in the development
version 0.90.2i; all will be included in 0.90.3i.

tlr <roessler@guug.de>, 98-02-09

diff -urN /var/tmp/mutt-0.89.1i/compose.c mutt-0.89.1i/compose.c
--- /var/tmp/mutt-0.89.1i/compose.c	Fri Jan 23 08:08:55 1998
+++ mutt-0.89.1i/compose.c	Mon Feb  9 20:58:18 1998
@@ -426,7 +426,10 @@
       case OP_COMPOSE_ATTACH_KEY:
 
 	if (idxlen == idxmax)
+        {
 	  safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+	  menu->data = idx;
+	}
 	
 	idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
 	if ((idx[idxlen]->content = pgp_make_key_attachment(NULL)) != NULL)
@@ -732,6 +735,7 @@
       case OP_FILTER:
 	CHECK_COUNT;
 	mutt_pipe_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, op == OP_FILTER);
+	   menu->redraw = REDRAW_CURRENT;
 	break;
 
       case OP_EXIT:
diff -urN /var/tmp/mutt-0.89.1i/doc/pgp-Notes.txt mutt-0.89.1i/doc/pgp-Notes.txt
--- /var/tmp/mutt-0.89.1i/doc/pgp-Notes.txt	Sat Jan 31 14:12:57 1998
+++ mutt-0.89.1i/doc/pgp-Notes.txt	Mon Feb  9 20:58:41 1998
@@ -33,41 +33,6 @@
 
 
 
-Q: "Why doesn't this work with PGP 5.0i-b8?"
-
-Because pgp-5.0i-b8 is not usable for our purpose:
-
-· pgp-5.0i-b8 doesn't support passing the pass phrase
-  through a previously-openend file descriptor (aka
-  PGPPASSFD).  This non-existing feature is required by
-  mutt.
-
-· pgp-5.0i-b8 doesn't support redirecting specific parts
-  of it's output to certain file descriptors (aka
-  --OutputInformationFD).
-
-But don't despair, the folks at www.pgpi.com are
-apparently working on a legally exported Unix release
-version of PGP which will most probably be able to do what
-we need.
-
-
-
-Q: "Why don't you use the SDK? It's available on the net!"
-
-The old answer on this question said something about
-illegal export and so on.  Well, www.pgpi.com has the SDK
-for quite some time now, so we could actually start using
-it.  
-
-But by now, most of the code needed to do the things we
-want to do is in place, and it's mostly independent of the
-PGP version you are using - PGP 5.*, PGP 2.*, g10. Support
-for other versions can easily be added by changing
-pgpinvoke.c.
-
-
-
 Q: "People are sending PGP messages which mutt doesn't
     recognize.  What can I do?"
 
@@ -113,6 +78,7 @@
 ------------------------------
 
 
+
 Q: "I don't like that PGP/MIME stuff, but want to use the
     old way of PGP-signing my mails.  Can't you include
     that with mutt?"
@@ -130,8 +96,3 @@
 
 
 
-If you encounter any bugs with mutt's PGP integration,
-please drop me a short note about what happens, how to
-reproduce it without illegally exporting PGP 5* from the
-U.S. and how to fix the problem.  I'll happily integrate
-any fixes with mutt's PGP support. 
diff -urN /var/tmp/mutt-0.89.1i/pgp.c mutt-0.89.1i/pgp.c
--- /var/tmp/mutt-0.89.1i/pgp.c	Sat Jan 31 14:12:57 1998
+++ mutt-0.89.1i/pgp.c	Mon Feb  9 20:58:34 1998
@@ -111,6 +111,9 @@
 
 char *pgp_keyid(KEYINFO *k)
 {
+  if((k->flags & KEYFLAG_SUBKEY) && k->mainkey)
+    k = k->mainkey;
+
   if(option(OPTPGPLONGIDS))
     return k->keyid;
   else
@@ -584,6 +587,8 @@
       return;
   }
 
+  memset(&s, 0, sizeof(STATE));
+  
   mutt_mktemp(tempfname);
   if(!(s.fpout = safe_fopen(tempfname, "w")))
   {
@@ -645,9 +650,12 @@
     mutt_perror(tempfname);
     return;
   }
+
+  memset(&s, 0, sizeof(STATE));
+  
   s.fpin = fp;
   s.fpout = tempfp;
-
+  
   mutt_body_handler(top, &s);
 
   fclose(tempfp);
@@ -676,10 +684,9 @@
       pgp_extract_keys_from_attachment (fp, top);
     
     if(!tag)
-      return;
+      break;
   }
   
-  mutt_any_key_to_continue(NULL);
   unset_option(OPTDONTHANDLEPGPKEYS);
 }
 
diff -urN /var/tmp/mutt-0.89.1i/pgpinvoke.c mutt-0.89.1i/pgpinvoke.c
--- /var/tmp/mutt-0.89.1i/pgpinvoke.c	Fri Jan 23 08:07:44 1998
+++ mutt-0.89.1i/pgpinvoke.c	Mon Feb  9 20:58:00 1998
@@ -235,7 +235,7 @@
       break;
 
     case PGP3:
-      snprintf(cmd, sizeof(cmd), "%sk +pubring=%s +secring=%s --OutputInformationFD=1 %s",
+      snprintf(cmd, sizeof(cmd), "%sk +pubring=%s +secring=%s -a --OutputInformationFD=1 %s",
 	       Pgp, PgpPubring, PgpSecring, fname);
       break;
 
@@ -289,7 +289,7 @@
       break;
 
     case PGP3:
-      snprintf(cmd, sizeof(cmd), "sk -xa +pubring=%s +secring=%s --OutputInformationFD=1 0x%8s",
+      snprintf(cmd, sizeof(cmd), "%sk -xa +pubring=%s +secring=%s --OutputInformationFD=1 0x%8s",
 	       Pgp, PgpPubring, PgpSecring, id);
       break;
 
diff -urN /var/tmp/mutt-0.89.1i/recvattach.c mutt-0.89.1i/recvattach.c
--- /var/tmp/mutt-0.89.1i/recvattach.c	Tue Jan 27 10:04:35 1998
+++ mutt-0.89.1i/recvattach.c	Mon Feb  9 20:58:21 1998
@@ -456,7 +456,14 @@
     return;
 
 #ifdef _PGPPATH
-  if (hdr->pgp == PGPENCRYPT && hdr->content->type == TYPEMULTIPART)
+  
+  if((hdr->pgp & PGPENCRYPT) && !pgp_valid_passphrase())
+  {
+    mx_close_message(&msg);
+    return;
+  }
+  
+  if ((hdr->pgp & PGPENCRYPT) && hdr->content->type == TYPEMULTIPART)
   {
     STATE s;
 
@@ -561,7 +568,7 @@
       case OP_LIST_REPLY:
       case OP_FORWARD_MESSAGE:
 #ifdef _PGPPATH
-	if (hdr->pgp == PGPENCRYPT && hdr->content->type == TYPEMULTIPART)
+	if ((hdr->pgp & PGPENCRYPT) && hdr->content->type == TYPEMULTIPART)
 	{
 	  mutt_error (
 	    "This operation is not currently supported for PGP messages.");
diff -urN /var/tmp/mutt-0.89.1i/send.c mutt-0.89.1i/send.c
--- /var/tmp/mutt-0.89.1i/send.c	Sat Jan 31 14:13:06 1998
+++ mutt-0.89.1i/send.c	Mon Feb  9 20:58:21 1998
@@ -361,7 +361,7 @@
 #ifdef _PGPPATH
   if (cur->pgp)
   {
-    if (cur->pgp == PGPENCRYPT)
+    if (cur->pgp & PGPENCRYPT)
     {
       /* make sure we have the user's passphrase before proceeding... */
       pgp_valid_passphrase ();
@@ -940,9 +940,9 @@
 	msg->pgp |= PGPSIGN;
       if (option (OPTPGPAUTOENCRYPT))
 	msg->pgp |= PGPENCRYPT;
-      if (option (OPTPGPREPLYENCRYPT) && cur && cur->pgp == PGPENCRYPT)
+      if (option (OPTPGPREPLYENCRYPT) && cur && cur->pgp & PGPENCRYPT)
 	msg->pgp |= PGPENCRYPT;
-      if (option (OPTPGPREPLYSIGN) && cur && cur->pgp == PGPSIGN)
+      if (option (OPTPGPREPLYSIGN) && cur && cur->pgp & PGPSIGN)
 	msg->pgp |= PGPSIGN;
     }
 #endif /* _PGPPATH */
