<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
Hello,<br>
<br>
I leafed through the definition of createTempFile in
sal/inc/osl/file.hxx. I read this too :
<a class="moz-txt-link-freetext" href="http://projects.cerias.purdue.edu/secprog/class2/6.Temp_&_Rand.ppt">http://projects.cerias.purdue.edu/secprog/class2/6.Temp_&_Rand.ppt</a>
<br>
"mktemp - generate temporary file name (unique)<br>
mkstemp - also create the file<br>
mkstemps - generate temporary file name with suffix<br>
mkdtemp - create a directory<br>
" and of course "no equivalent of these functions in Windows" for
example.<br>
<br>
<br>
So I thought this :<br>
1) for common part between Windows and other systems (Unix/Linux/BSD
and Mac) or for Windows specific, only createTempFile should be
used.<br>
2) for Unix/Linux/BSD and Mac only part, mkstemp/mktemp should be
used (to avoid overhead)<br>
<br>
So tmpnam shouldn't be used at all.<br>
<br>
Is this ok ?<br>
<br>
Julien.<br>
<br>
<br>
-------- Message original --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Sujet: </th>
<td>warning: the use of `tmpnam' is dangerous, better use
`mkstemp'</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Date : </th>
<td>Thu, 09 Jun 2011 23:24:16 +0200</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">De : </th>
<td>Julien Nabet <a class="moz-txt-link-rfc2396E" href="mailto:serval2412@yahoo.fr"><serval2412@yahoo.fr></a></td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Pour : </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:libreoffice@lists.freedesktop.org">libreoffice@lists.freedesktop.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>Hello,
I had this warning by compiling hwpfilter during some cppcheck cleaning.
I knew nothing about it so I read some links given by Google.
It seems mkstemp is safer since it permits "to avoid race conditions".
In the Unix man of tmpnam, we can read this :
"
BUGS
Never use this function. Use mkstemp(3) or tmpfile(3) instead.
"
I'm just a beginner in C++ so what's your opinion about it ?
Julien
</pre>
</body>
</html>