|
NAMEtempnam , tmpfile ,
tmpnam —
temporary file routines
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <stdio.h>
FILE *
char *
char *
DESCRIPTIONThetmpfile () function returns a pointer to a stream
associated with a file descriptor returned by the routine
mkstemp(3).
The created file is unlinked before tmpfile () returns,
causing the file to be automatically deleted when the last reference to it is
closed. The file is opened with the access value
‘w+ ’. The file is created in the
directory determined by the environment variable
TMPDIR if set. The default location if
TMPDIR is not set is /tmp.
The The buffer referenced by str is expected to
be at least The The environment variable The argument prefix, if
non- RETURN VALUESThetmpfile () function returns a pointer to an open file
stream on success, and a NULL pointer on error.
The ENVIRONMENT
COMPATIBILITYThese interfaces are provided from System V and ANSI compatibility only.Most historic implementations of these functions provide only a limited number of possible temporary file names (usually 26) before file names will start being recycled. System V implementations of these functions (and of mktemp(3)) use the access(2) system call to determine whether or not the temporary file may be created. This has obvious ramifications for setuid or setgid programs, complicating the portable use of these interfaces in such programs. The ERRORSThetmpfile () function may fail and set the global
variable errno for any of the errors specified for the
library functions
fdopen(3)
or
mkstemp(3).
The The SEE ALSOmkstemp(3), mktemp(3)STANDARDSThetmpfile () and tmpnam ()
functions conform to ISO/IEC 9899:1990
(“ISO C90”).
SECURITY CONSIDERATIONSThetmpnam () and tempnam ()
functions are susceptible to a race condition occurring between the selection
of the file name and the creation of the file, which allows malicious users to
potentially overwrite arbitrary files in the system, depending on the level of
privilege of the running program. Additionally, there is no means by which
file permissions may be specified. It is strongly suggested that
mkstemp(3)
be used in place of these functions.
Visit the GSP FreeBSD Man Page Interface. |