note 41936 deleted from function.tempnam by betz
| From: | betz@php.net | Date: | Tue, 27 Apr 2004 09:51:44 +0000 |
| Subject: | note 41936 deleted from function.tempnam by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-68858@lists.php.net to get a copy of this message | ||
Note Submitter: jhuiskam@NOuoguelphSPAM.ca
----
In the code displayed below is the race condition really a problem, since the file will be opened
and truncated anyways?
Or would this be an acceptable solution?:
<?php
/* ... */
do{
$seed = substr(md5(microtime().posix_getpid()), 0, 8);
$filename = $dir . $trailing_slash . $prefix . $seed . $postfix;
} while (!($fp = fopen($filename, "x")));
fclose($fp);
return $filename;
/* ... */
?>