php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45316 tempnam silently fail
Submitted: 2008-06-19 14:51 UTC Modified: 2008-06-28 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: elettrico at diciannove dot net Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: elettrico at diciannove dot net
New email:
PHP Version: OS:

 

 [2008-06-19 14:51 UTC] elettrico at diciannove dot net
Description:
------------
I'm setting up a virtualhost with this configuration:

    php_admin_value  open_basedir      "/home/data/web/tdo:/home/data/tdo/tmp:/home/sys/apache2/errorpages/:/usr/lib/php/:/tmp"
    php_admin_value  doc_root          "/home/data/web/tdo/"
    php_admin_value  include_path      "/home/data/web/tdo/:/home/sys/apache2/errorpages/:/usr/lib/php/"
    php_admin_value  session.save_path "/home/data/tdo/sess/"
    php_admin_value  upload_tmp_dir    "/home/data/tdo/tmp/"

a simple page that try to do a fopen and after a fwrite fail to execute, after investigating a little I'll see that it's the tempnam() function that fail, after fail the fopen, also without issuing any error, and finally the fwrite, that fire ad error:

Warning: fwrite(): supplied argument is not a valid stream resource in /home/data/web/tdo/test.php on line 7

Warning: fclose(): supplied argument is not a valid stream resource in /home/data/web/tdo/test.php on line 8

I don't see any problem in my configuration nor in my code, my php version is the version of the debian package:

PHP 5.2.0-8+etch11 (cli) (built: May 10 2008 10:35:46) 

Reproduce code:
---------------
$tmpfname = tempnam("", "");
//it's the same with $tmpfname = tempnam("*", "");
$handle = fopen($tmpfname, "w");
fwrite($handle, "writing to tempfile");
fclose($handle);


Expected result:
----------------
A file opened in the system TMPDIR (/tmp) or an error.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-20 08:50 UTC] elettrico at diciannove dot net
I've tested today, it's the same thing with Apache/2.2.8 and PHP/5.2.5-3 (debian lenny package)
 [2008-06-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC