]> diplodocus.org Git - nmh/commitdiff
Replaced use of mkstemp() with m_mktemp2() in header_fd() of
authorDavid Levine <levinedl@acm.org>
Fri, 24 Jan 2014 04:16:34 +0000 (22:16 -0600)
committerDavid Levine <levinedl@acm.org>
Fri, 24 Jan 2014 04:16:34 +0000 (22:16 -0600)
rcvtty.c.  It never would have worked, anyway, because it had 5
instead of 6 X's in the template.

uip/rcvtty.c

index 760d22dc839ed25b06e59b0ad44a5be2c7f0c066..9dd862c7bc6da2e14ec3d00f671bd9c9043c6430 100644 (file)
@@ -189,13 +189,14 @@ message_fd (char **vec)
 {
     pid_t child_id;
     int bytes, seconds;
-    /* volatile to prevent "might be clobbered" warning from gcc: */
-    volatile int fd;
-    char tmpfil[BUFSIZ];
+    int fd;
+    char *tfile;
     struct stat st;
 
-    fd = mkstemp (strncpy (tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil)));
-    unlink (tmpfil);
+    if ((tfile = m_mktemp2(NULL, invo_name, &fd, NULL)) == NULL) {
+       advise(NULL, "unable to create temporary file in %s", get_temp_dir());
+       return NOTOK;
+    }
 
     if ((child_id = fork()) == NOTOK) {
        /* fork error */
@@ -259,7 +260,6 @@ header_fd (void)
        advise(NULL, "unable to create temporary file in %s", get_temp_dir());
         return NOTOK;
     }
-    unlink (tfile);
 
     rewind (stdin);