|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23069 tempnam creates readonly file
Submitted: 2003-04-06 07:53 UTC Modified: 2004-12-22 10:40 UTC
From: paj at pearfr dot org Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 4CVS-2003-04-06 (stable) OS: Windows 2000
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.
Block user comment
Status: Assign to:
Bug Type:
From: paj at pearfr dot org
New email:
PHP Version: OS:


 [2003-04-06 07:53 UTC] paj at pearfr dot org
tempnam() creates a readonly file under Windows 2K using Apache 1.3.27, php as CGI. The file permissions are correct but it sets the RO flag, which is not really usefull ;)



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-07 16:13 UTC]
Marking this critical as it prevents much anticipated pear on windows release.
 [2003-04-07 16:14 UTC]
Just forgot to mention that I have reproduced this using latest win32 cli.
 [2003-04-08 02:28 UTC]
It is critical in general too, not only for PEAR, afaik, this is the only way to get a safe temp name and seems to be widely used.

I cannot reproduce it with the stable snapshot from 03/4/4 on w2K CLI.


 [2003-04-11 04:09 UTC]
Can you try this patch? untested, but should work...

Index: main/php_open_temporary_file.c
RCS file: /repository/php4/main/php_open_temporary_file.c,v
retrieving revision 1.25
diff -u -p -r1.25 php_open_temporary_file.c
--- main/php_open_temporary_file.c      18 Mar 2003 16:40:29 -0000      1.25
+++ main/php_open_temporary_file.c      11 Apr 2003 09:09:15 -0000
@@ -132,7 +132,8 @@ static int php_do_open_temporary_file(co

 #ifdef PHP_WIN32
        if (GetTempFileName(path, pfx, 0, opened_path)) {
-               fd = VCWD_OPEN(opened_path, open_flags);
+               VCWD_CHMOD(opened_path, 0600);
+               fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600);
 #elif defined(NETWARE)
        /* Using standard mktemp() implementation for NetWare */

 [2003-04-11 06:12 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 14:01:28 2024 UTC