php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47037 No error when using fopen with emty string
Submitted: 2009-01-08 14:37 UTC Modified: 2009-01-08 19:23 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: yarontal12 at gmail dot com Assigned: felipe
Status: Closed Package: Filesystem function related
PHP Version: 5.2CVS-2009-01-08 (snap) OS: Win XP
Private report: No CVE-ID:
 [2009-01-08 14:37 UTC] yarontal12 at gmail dot com
Description:
------------
$fh = fopen("", "r");
that doesn't produce an error, but doesn't return a valid stream either.
Same problem with passing NULL or ''.

Reproduce code:
---------------
$fh = fopen("", "r");

Expected result:
----------------
Warning: fopen() [function.fopen]: failed to open stream: No such file or directory in test.php on line 2

Actual result:
--------------
nothing

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-08 15:48 UTC] crrodriguez at opensuse dot org
Yeah, I agree with you.

Index: main/streams/streams.c
===================================================================
RCS file: /repository/php-src/main/streams/streams.c,v
retrieving revision 1.82.2.6.2.31
diff -u -p -r1.82.2.6.2.31 streams.c
--- main/streams/streams.c      24 Nov 2008 15:37:33 -0000      1.82.2.6.2.31
+++ main/streams/streams.c      8 Jan 2009 15:47:34 -0000
@@ -1763,6 +1763,7 @@ PHPAPI php_stream *_php_stream_open_wrap
        }

        if (!path || !*path) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot be empty");
                return NULL;
        }
 [2009-01-08 19:23 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5_2, 5_3 and HEAD.

Thanks.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 08:02:55 2014 UTC