From dcce4cdb778ccde18c47a02c636aa853991fbc67 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 15 Dec 2017 12:09:42 -0800 Subject: [PATCH] Fix s/mime certificate deletion bug 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. Fixes #1006 --- ncrypt/smime.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 5b47c5a51..866e7fb98 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -1356,8 +1356,8 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) if (!smimeerr) { mutt_perror(smimeerrfile); - mutt_file_fclose(&fpout); mutt_file_unlink(tempfile); + mutt_file_fclose(&fpout); return NULL; } mutt_file_unlink(smimeerrfile); @@ -1399,10 +1399,10 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) fileno(smimeerr), smimeinfile, certfile); if (thepid == -1) { + mutt_file_unlink(tempfile); + mutt_file_fclose(&fpout); mutt_file_fclose(&smimeerr); mutt_file_unlink(smimeinfile); - mutt_file_unlink(certfile); - mutt_file_fclose(&fpout); return NULL; } @@ -1410,7 +1410,6 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) mutt_wait_filter(thepid); mutt_file_unlink(smimeinfile); - mutt_file_unlink(certfile); fflush(fpout); rewind(fpout); -- 2.40.0