Bug #78672 [Opn->Nab]: file_get_contents returns NULL instead of FALSE
| From: | cmb@php.net | Date: | Mon, 14 Oct 2019 12:18:37 +0000 |
| Subject: | Bug #78672 [Opn->Nab]: file_get_contents returns NULL instead of FALSE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-223201@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78672&edit=1
ID: 78672
Updated by: cmb@php.net
Reported by: php dot net-11012019 at 0pe dot de
Summary: file_get_contents returns NULL instead of FALSE
-Status: Open
+Status: Not a bug
Type: Bug
Package: Streams related
Operating System: Arch Linux
PHP Version: 7.3.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
See the note on <https://www.php.net/manual/en/functions.internal.php>.
Previous Comments:
------------------------------------------------------------------------
[2019-10-14 12:04:02] php dot net-11012019 at 0pe dot de
Description:
------------
When injecting 0 byte in first parameter of file_get_contents this will produce a warning and should
return FALSE according PHP documentation. But the return is NULL.
Test script:
---------------
$fc1 = file_get_contents("not-existing-file.txt");
$fc2 = file_get_contents("not-existing-file.txt\0");
echo PHP_EOL;
var_dump($fc1);
var_dump($fc2);
Expected result:
----------------
PHP Warning: file_get_contents(not-existing-file.txt): failed to open stream: No such file or
directory in /home/arch/php-fgc-test.php on line 2
PHP Warning: file_get_contents() expects parameter 1 to be a valid path, string given in
/home/arch/php-fgc-test.php on line 3
bool(false)
bool(false)
Actual result:
--------------
PHP Warning: file_get_contents(not-existing-file.txt): failed to open stream: No such file or
directory in /home/arch/php-fgc-test.php on line 2
PHP Warning: file_get_contents() expects parameter 1 to be a valid path, string given in
/home/arch/php-fgc-test.php on line 3
bool(false)
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78672&edit=1