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: -
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2019 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 20:01:28 2019 UTC