- Tmpfile
In
computing ,tmpfile
is anISO C /POSIX function for creating atemporary file , acomputer file which ceases to exist when the program, which opened the file, closes it or terminates. [http://www.opengroup.org/onlinepubs/009695399/functions/tmpfile.html tmpfile] byOpenGroup ] [ [http://www.gnu.org/software/libtool/manual/libc/Temporary-Files.html Temporary Files] byGNU C Library ] [ [http://www.hmug.org/man/3/tmpfile.php tmpfile] by HMUG]Usage
Inclusion
; C
#include
; C++#include
Declaration
FILE* tmpfile(void);
emantics
The function
tmpfile
reports a pointer to a valid file stream on success; on failure, it returnsNULL
.Error conditions
In addition to returning
NULL
,tmpfile
sets
on failure. The permissible values oferrno
, iferrno tmpfile
fails, are:
*EINTR
- if a signal was caught during the execution of tmpfile.
*EMFILE
- if the maximum number of file descriptors and/or the maximum number of file streams has been reached (in the process).
*ENFILE
- if the maximum allowable number of files is currently open (in the system).
*ENOSPC
- if there is no space in the file system for creating the temporary file.
*EOVERFLOW
- if the file is a regular file and the size of the file cannot be represented correctly in an object of type off_t.
*ENOMEM
- if there is insufficient memory for allocating the file stream.Caveats
The
tmpfile
function is susceptible to a number of security vulnerabilities; use the non-portable
(mkstemp UNIX ) or
(tmpfile_s Windows ) functions, instead, to avoid these issues. [ [https://buildsecurityin.us-cert.gov/daisy/bsi-rules/home/g1/861-BSI.html TMPNAM-TMPFILE Vulnerability] byBuild Security In ] [https://www.securecoding.cert.org/confluence/display/seccode/VOID+FI039-C.+Create+temporary+files+securely VOID FI039-C. Create temporary files securely] byCERT ]References
ee also
*
mkstemp
*fopen
*fclose
*stdio.h
Wikimedia Foundation. 2010.