* Bug #15213, #18635: The use of the insecure m_scratch() and
[mmh] / uip / prompter.c
index 35f6860..6f97a88 100644 (file)
@@ -108,6 +108,7 @@ main (int argc, char **argv)
     char buffer[BUFSIZ], tmpfil[BUFSIZ];
     char **arguments, **argp;
     FILE *in, *out;
+    char *tfile = NULL;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -185,10 +186,10 @@ main (int argc, char **argv)
     if ((in = fopen (drft, "r")) == NULL)
        adios (drft, "unable to open");
 
-    strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil));
-    if ((out = fopen (tmpfil, "w")) == NULL)
-       adios (tmpfil, "unable to create");
+    tfile = m_mktemp2(NULL, invo_name, NULL, &out);
+    if (tfile == NULL) adios("prompter", "unable to create temporary file");
     chmod (tmpfil, 0600);
+    strncpy (tmpfil, tfile, sizeof(tmpfil));
 
     /*
      * Are we changing the kill or erase character?