From 099f4dd473cb2936d6fe064539f9951d23c77efc Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 1 Jul 2018 20:13:11 -0700 Subject: [PATCH] Void passphrase on s/mime decryption error. Model this after pgp's pgp_decrypt_part(), which checks if fpout is empty. --- smime.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/smime.c b/smime.c index 13a3e2cc..e96daec7 100644 --- a/smime.c +++ b/smime.c @@ -1930,6 +1930,17 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile) { fflush (smimeout); rewind (smimeout); + + if (type & ENCRYPT) + { + /* void the passphrase, even if that wasn't the problem */ + if (fgetc (smimeout) == EOF) + { + mutt_error _("Decryption failed"); + smime_void_passphrase (); + } + rewind (smimeout); + } if (outFile) fpout = outFile; else @@ -1955,7 +1966,6 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile) fflush (fpout); rewind (fpout); - if ((p = mutt_read_mime_header (fpout, 0)) != NULL) { fstat (fileno (fpout), &info); @@ -1972,6 +1982,7 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile) } } + safe_fclose (&smimeout); smimeout = NULL; mutt_unlink (outfile); -- 2.40.0