From: David Levine Date: Fri, 24 Jan 2014 04:16:34 +0000 (-0600) Subject: Replaced use of mkstemp() with m_mktemp2() in header_fd() of X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/a404a36988ef8eb4b640bdd1d3f30298e0ca5182?ds=inline;hp=-c Replaced use of mkstemp() with m_mktemp2() in header_fd() of rcvtty.c. It never would have worked, anyway, because it had 5 instead of 6 X's in the template. --- a404a36988ef8eb4b640bdd1d3f30298e0ca5182 diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 760d22dc..9dd862c7 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -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);