]> granicus.if.org Git - neomutt/commitdiff
Remove tempfile from pgp_gpgme_decrypt_mime
authorMarco Sirabella <marco@sirabella.org>
Fri, 22 Jun 2018 18:48:38 +0000 (14:48 -0400)
committerRichard Russon <rich@flatcap.org>
Sat, 23 Jun 2018 14:52:17 +0000 (15:52 +0100)
ncrypt/crypt_gpgme.c

index 61ffb065a35d66d9db15286589fc44ca6b45f6ba..a1fb0d26dc4a12fb28be11b603a78916721e8852 100644 (file)
@@ -1912,7 +1912,6 @@ restart:
  */
 int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
 {
-  char tempfile[PATH_MAX];
   struct State s = { 0 };
   struct Body *first_part = b;
   int is_signed = 0;
@@ -1944,14 +1943,12 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
     saved_offset = b->offset;
     saved_length = b->length;
 
-    mutt_mktemp(tempfile, sizeof(tempfile));
-    decoded_fp = mutt_file_fopen(tempfile, "w+");
+    decoded_fp = mutt_file_mkstemp();
     if (!decoded_fp)
     {
-      mutt_perror(tempfile);
+      mutt_perror("mutt_file_mkstemp() failed!");
       return -1;
     }
-    unlink(tempfile);
 
     fseeko(s.fpin, b->offset, SEEK_SET);
     s.fpout = decoded_fp;
@@ -1966,15 +1963,13 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
     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;
   }
-  unlink(tempfile);
 
   *cur = decrypt_part(b, &s, *fpout, false, &is_signed);
   if (!*cur)