php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78672 file_get_contents returns NULL instead of FALSE
Submitted: 2019-10-14 12:04 UTC Modified: 2019-10-14 12:18 UTC
From: php dot net-11012019 at 0pe dot de Assigned: cmb (profile)
Status: Not a bug Package: Streams related
PHP Version: 7.3.10 OS: Arch Linux
Private report: No CVE-ID: None
 [2019-10-14 12:04 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-14 12:18 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2019-10-14 12:18 UTC] cmb@php.net
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>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC