This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/47439] Fun with scratch files on Windows MKTEMP only allows for 26 files
- From: "jb at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Jan 2011 09:28:16 +0000
- Subject: [Bug fortran/47439] Fun with scratch files on Windows MKTEMP only allows for 26 files
- Auto-submitted: auto-generated
- References: <bug-47439-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439
--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-01-25 09:28:14 UTC ---
Seems the reason for Windows _mktemp() behavior is due to replicating some
age-old BSD behavior. From the Linux mktemp(3) manpage:
BUGS
Never use mktemp(). Some implementations follow 4.3BSD and replace
XXXXXX by the current process ID and a single
letter, so that at most 26 different names can be returned. Since on
the one hand the names are easy to guess,
and on the other hand there is a race between testing whether the name
exists and opening the file, every use of
mktemp() is a security risk. The race is avoided by mkstemp(3).
(Needless to say, libgfortran use mkstemp() ifavailable, mktemp() is just a
fallback.)