Use file descriptor instead of path for mutt_decode_save_attachment()
[apps/madmutt.git] / recvattach.c
index 301b12e..6c7956a 100644 (file)
@@ -633,10 +633,10 @@ static void print_attachment_list (FILE * fp, int tag, BODY * top,
 
           char newfile[_POSIX_PATH_MAX] = "";
           FILE *ifp;
+          int newfile_fd;
 
-          mutt_mktemp (newfile);
-          if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
-              0) {
+          newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(Tempdir), NULL);
+          if (mutt_decode_save_attachment (fp, top, newfile_fd, M_PRINTING) == 0) {
             if ((ifp = fopen (newfile, "r")) != NULL) {
               mutt_copy_stream (ifp, state->fpout);
               m_fclose(&ifp);