No error when using fopen with emty string
| Bug #47037 | No error when using fopen with emty string | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-01-08 14:37 UTC | Modified: | 2009-01-08 19:23 UTC |
|
||||||||||
| From: | yarontal12 at gmail dot com | Assigned: | felipe (profile) | |||||||||||
| Status: | Closed | Package: | Filesystem function related | |||||||||||
| PHP Version: | 5.2CVS-2009-01-08 (snap) | OS: | Win XP | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[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
Pull Requests
History
AllCommentsChangesGit/SVN commits
[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