From: Marco Sirabella Date: Fri, 22 Jun 2018 18:39:10 +0000 (-0400) Subject: Remove tempfile from smime_class_decrypt_mime X-Git-Tag: neomutt-20180716~24^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18f45eabd3480679bcc6afa0ea8cff45fa70eac2;p=neomutt Remove tempfile from smime_class_decrypt_mime --- diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 3c1fc5a0c..c44868f92 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -2018,12 +2018,10 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o */ int smime_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur) { - char tempfile[PATH_MAX]; struct State s = { 0 }; LOFF_T tmpoffset = b->offset; size_t tmplength = b->length; int orig_type = b->type; - FILE *tmpfp = NULL; int rc = 0; if (!mutt_is_application_smime(b)) @@ -2035,15 +2033,13 @@ int smime_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Bo s.fpin = fpin; fseeko(s.fpin, b->offset, SEEK_SET); - mutt_mktemp(tempfile, sizeof(tempfile)); - tmpfp = mutt_file_fopen(tempfile, "w+"); + FILE *tmpfp = mutt_file_mkstemp(); if (!tmpfp) { - mutt_perror(tempfile); + mutt_perror("mutt_file_mkstemp() failed!"); return -1; } - mutt_file_unlink(tempfile); s.fpout = tmpfp; mutt_decode_attachment(b, &s); fflush(tmpfp); @@ -2053,15 +2049,13 @@ int smime_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Bo s.fpin = tmpfp; s.fpout = 0; - mutt_mktemp(tempfile, sizeof(tempfile)); - *fpout = mutt_file_fopen(tempfile, "w+"); + *fpout = mutt_file_mkstemp(); if (!*fpout) { - mutt_perror(tempfile); + mutt_perror("mutt_file_mkstemp() failed!"); rc = -1; goto bail; } - mutt_file_unlink(tempfile); *cur = smime_handle_entity(b, &s, *fpout); if (!*cur)