summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2017-12-15 12:09:42 -0800
committerKevin McCarthy <kevin@8t8.us>2017-12-15 12:09:42 -0800
commit9eedfd4e1b62d1749f7e93d85fb0930e7d2cdf8f (patch)
tree51aee4f333dd7429db9b0c58cf7b65320d3558c4
parent841f7101c653c54f51dc1001768d1dae0f79fbbd (diff)
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 use. 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.
-rw-r--r--smime.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/smime.c b/smime.c
index f447d56a..0ba58a1f 100644
--- a/smime.c
+++ b/smime.c
@@ -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);