From: Kevin McCarthy Date: Fri, 15 Dec 2017 20:09:42 +0000 (-0800) Subject: Fix s/mime certificate deletion bug X-Git-Tag: neomutt-20180223~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcce4cdb778ccde18c47a02c636aa853991fbc67;p=neomutt 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 --- 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);