Use m_tempfile()
authorJulien Danjou <julien@danjou.info>
Sat, 25 Nov 2006 17:10:47 +0000 (18:10 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 26 Nov 2006 16:09:22 +0000 (17:09 +0100)
Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
lib-crypt/pgpkey.c

index a3b3ca2..16d9e4c 100644 (file)
@@ -500,13 +500,14 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, address_t * p, const char *s)
 
     case OP_VERIFY_KEY:
 
 
     case OP_VERIFY_KEY:
 
-      mutt_mktemp (tempfile);
       if ((devnull = fopen ("/dev/null", "w")) == NULL) {       /* __FOPEN_CHECKED__ */
         mutt_perror (_("Can't open /dev/null"));
 
         break;
       }
       if ((devnull = fopen ("/dev/null", "w")) == NULL) {       /* __FOPEN_CHECKED__ */
         mutt_perror (_("Can't open /dev/null"));
 
         break;
       }
-      if ((fp = safe_fopen (tempfile, "w")) == NULL) {
+
+      fp = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+      if (!fp) {
         m_fclose(&devnull);
         mutt_perror (_("Can't create temporary file"));
 
         m_fclose(&devnull);
         mutt_perror (_("Can't create temporary file"));
 
@@ -682,13 +683,14 @@ BODY *pgp_make_key_attachment (char *tempf)
   pgp_free_key (&key);
 
   if (!tempf) {
   pgp_free_key (&key);
 
   if (!tempf) {
-    mutt_mktemp (tempfb);
+    tempfp = m_tempfile (tempfb, sizeof(tempfb), NONULL(Tempdir), NULL);
     tempf = tempfb;
     tempf = tempfb;
+  } else {
+    tempfp = safe_fopen(tempf, "a");
   }
 
   }
 
-  if ((tempfp = safe_fopen (tempf, tempf == tempfb ? "w" : "a")) == NULL) {
+  if (!tempfp) {
     mutt_perror (_("Can't create temporary file"));
     mutt_perror (_("Can't create temporary file"));
-
     return NULL;
   }
 
     return NULL;
   }