Commit 9eedfd4e authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Fix s/mime certificate deletion bug. (closes #3982)

Commit c1bcf4ba exposed a bug in the s/mime encryption code.  It was
errorneously calling unlink on the list of generated cert files to

Prior to that commit, the list had an initial space, which apparently
made the unlink fail.  After that commit, encrypting to a single
certificate would end up deleting the certificate.

Remove the calls to unlink the cert file.  Add some missing cleanup if
the call to openssl fails.
parent 841f7101
......@@ -1391,8 +1391,8 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
if ((smimeerr = safe_fopen (smimeerrfile, "w+")) == NULL)
mutt_perror (smimeerrfile);
safe_fclose (&fpout);
mutt_unlink (tempfile);
safe_fclose (&fpout);
return NULL;
mutt_unlink (smimeerrfile);
......@@ -1433,9 +1433,10 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
fileno (fpout), fileno (smimeerr),
smimeinfile, certfile)) == -1)
mutt_unlink (tempfile);
safe_fclose (&fpout);
safe_fclose (&smimeerr);
mutt_unlink (smimeinfile);
mutt_unlink (certfile);
return (NULL);
......@@ -1443,7 +1444,6 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
mutt_wait_filter (thepid);
mutt_unlink (smimeinfile);
mutt_unlink (certfile);
fflush (fpout);
rewind (fpout);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment