From: Kevin McCarthy Date: Thu, 5 Mar 2015 03:24:31 +0000 (-0800) Subject: Fix pgp_application_pgp_handler to remove all tempfiles. X-Git-Tag: neomutt-20160307~79 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6068aba66450b48f1f53e1714a38fe5ef4319c84;p=neomutt Fix pgp_application_pgp_handler to remove all tempfiles. If multiple PGP blocks are present in an email, Mutt only cleans up the tempfiles for the last block. Thanks to Dennis Preiser for the patch and sample mbox file demonstrating the problem. This patch also fixes the argument to mutt_perror for the pgpout tempfile. --- diff --git a/pgp.c b/pgp.c index ee9751f02..655077715 100644 --- a/pgp.c +++ b/pgp.c @@ -373,7 +373,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s) mutt_mktemp (outfile, sizeof (outfile)); if ((pgpout = safe_fopen (outfile, "w+")) == NULL) { - mutt_perror (tmpfname); + mutt_perror (outfile); return -1; } @@ -485,6 +485,18 @@ int pgp_application_pgp_handler (BODY *m, STATE *s) fgetconv_close (&fc); } + /* + * Multiple PGP blocks can exist, so these need to be closed and + * unlinked inside the loop. + */ + safe_fclose (&tmpfp); + mutt_unlink (tmpfname); + if (pgpout) + { + safe_fclose (&pgpout); + mutt_unlink (outfile); + } + if (s->flags & M_DISPLAY) { state_putc ('\n', s);