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: Open Package: Streams related
PHP Version: master-Git-2018-09-10 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jan 29 09:01:25 2020 UTC