Hello,

I've observed the following issue with mutt 1.5.21 (2010-09-15):

I've had received a traditional pgp message which contained a public
key.  After invoking <check-traditional-pgp> (Esc P) there are two
leftover files in $TMPDIR.

Root cause seems to be pgp.c:pgp_application_pgp_handler().  If a
PGP-key is included mutt_mktemp() and safe_fopen() is called twice for
tmpfname and outfile without closing and unlinking before.

The patch below fixes this for me.

Dennis
diff -urp mutt-1.5.21/pgp.c mutt-1.5.21_r1/pgp.c
--- mutt-1.5.21/pgp.c   2010-09-13 19:19:55.000000000 +0200
+++ mutt-1.5.21_r1/pgp.c        2011-10-04 19:16:15.000000000 +0200
@@ -424,6 +424,16 @@ int pgp_application_pgp_handler (BODY *m
           mutt_error _("Could not decrypt PGP message");
          mutt_sleep (1);
          rc = -1;
+         if (tmpfp)
+         {
+           safe_fclose (&tmpfp);
+           mutt_unlink (tmpfname);
+         }
+         if (pgpout)
+         {
+           safe_fclose (&pgpout);
+           mutt_unlink (outfile);
+         }
          goto out;
         }
       }
@@ -481,6 +491,16 @@ int pgp_application_pgp_handler (BODY *m
        else
          state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
       }
+      if (tmpfp)
+      {
+        safe_fclose (&tmpfp);
+        mutt_unlink (tmpfname);
+      }
+      if (pgpout)
+      {
+        safe_fclose (&pgpout);
+        mutt_unlink (outfile);
+      }
     }
     else
     {
@@ -497,17 +517,6 @@ int pgp_application_pgp_handler (BODY *m
 out:
   m->goodsig = (maybe_goodsig && have_any_sigs);
 
-  if (tmpfp)
-  {
-    safe_fclose (&tmpfp);
-    mutt_unlink (tmpfname);
-  }
-  if (pgpout)
-  {
-    safe_fclose (&pgpout);
-    mutt_unlink (outfile);
-  }
-
   FREE(&gpgcharset);
 
   if (needpass == -1)

Reply via email to