* Bug #15213, #18635: The use of the insecure m_scratch() and
[mmh] / sbr / m_tmpfil.c
1 /*
2  * m_tmpfil.c -- construct a temporary file
3  *
4  * $Id$
5  *
6  * This code is Copyright (c) 2002, by the authors of nmh.  See the
7  * COPYRIGHT file in the root directory of the nmh distribution for
8  * complete copyright information.
9  */
10
11 #include <h/mh.h>
12
13 /***************************************************************************
14  * DO NOT USE THIS FUNCTION!  IT WILL BE REMOVED IN THE FUTURE.
15  * THIS FUNCTION IS INSECURE.  USE THE FUNCTIONS DEFINED IN m_mktemp.c.
16  ***************************************************************************/
17 char *
18 m_tmpfil (char *template)
19 {
20     static char tmpfil[BUFSIZ];
21
22     snprintf (tmpfil, sizeof(tmpfil), "/tmp/%sXXXXXX", template);
23 /*
24   Mkstemp work postponed until later -Doug
25 #ifdef HAVE_MKSTEMP
26     unlink(mkstemp(tmpfil));
27 #else
28 */
29     unlink(mktemp(tmpfil));
30 /*
31 #endif
32 */
33     return tmpfil;
34 }