php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5509 tempnam() is not safe
Submitted: 2000-07-11 11:27 UTC Modified: 2000-07-11 11:30 UTC
From: alban dot hertroys at ddnh dot nl Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alban dot hertroys at ddnh dot nl
New email:
PHP Version: OS:

 

 [2000-07-11 11:27 UTC] alban dot hertroys at ddnh dot nl
$filename = tempnam("/tmp", "blah");

<do all kinds of stuff that takes more than 0 seconds>

$fd = fopen($filename, "w+");

This could result in another proces on the system creating a temp-file with the same name in the meantime, which then will be overwritten by PHP.

See man mkstemp on any UNIX for more details and the solution to the same problem (returning a file descriptor of a newly opened temp-file instead of a filename).

It could be that PHP found a way to magically circumvent the problem, but that is not documented anywhere I looked.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-11 11:30 UTC] stas at cvs dot php dot net
This is not a bug. tempnam is not safe, everybody knows that, so don't use it if your stuff is security-sensitive. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 07:01:30 2024 UTC