php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76857 Can read “non-existant” files
Submitted: 2018-09-10 14:38 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: cmb@php.net Assigned:
Status: Closed Package: Streams related
PHP Version: master-Git-2018-09-10 (Git) OS: Linux
Private report: No CVE-ID: None
 [2018-09-10 14:38 UTC] cmb@php.net
Description:
------------
If an URL with an unsupported protocol is passed to filesystem
functions, they treat it as local file path (after raising an
E_WARNING).  On Linux, however, file_get_contents() and others may
succeed, even if file_exists() returns FALSE (Windows returns
TRUE).

The test script is supposed to be placed in
ext/standard/tests/streams/ and to be run from the php-src root.



Test script:
---------------
<?php
$path = "foobar://google.com/../../INSTALL";
var_dump(file_exists($path));
var_dump(file_get_contents($path, false, null, 0, 10));
?>

Expected result:
----------------
Warning: file_exists(): Unable to find the wrapper "foobar" - did you forget to enable it when you configured PHP? in %s on line %d
bool(true)

Warning: file_get_contents(): Unable to find the wrapper "foobar" - did you forget to enable it when you configured PHP? in %s on line %d
string(10) "For instal"

Actual result:
--------------
Warning: file_exists(): Unable to find the wrapper "foobar" - did you forget to enable it when you configured PHP? in %s on line %d
bool(false)

Warning: file_get_contents(): Unable to find the wrapper "foobar" - did you forget to enable it when you configured PHP? in %s on line %d
string(10) "For instal"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2023-08-28 15:54 UTC] git@php.net
Automatic comment on behalf of bukka
Revision: https://github.com/php/php-src/commit/766cac072f396dd0914d9d8f1209b673d54b61c1
Log: Fix bug #76857: Can read &quot;non-existant&quot; files
 [2023-08-28 15:54 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC