php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67085 filesystem functions don't handle anonymous pipes correctly
Submitted: 2014-04-16 14:05 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: yuri dot kanivetsky at gmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.5.11 OS: arch linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-04-16 14:05 UTC] yuri dot kanivetsky at gmail dot com
Description:
------------
php's filesystem functions can't handle files like /dev/fd/*, e.g.:

$ php -d open_basedir= -r 'var_dump(file_get_contents($_SERVER["argv"][1]));' -- <(echo test)

As opposed to other languages, including C:

$ ruby -e 'p File.read ARGV[0]' <(echo test)
$ perl -e 'open F, @ARGV[0]; print <F>' <(echo test)
$ cat <(echo test)
$ node -e 'var fs = require("fs"); fs.readFile(process.argv[1], "utf8", function(err, data) { console.log(data); })' <(echo test)

Please consider explaining what prevents php from opening such files, if you don't consider it a bug. See the following question on unix.stackexchange.com for more details:

http://unix.stackexchange.com/questions/74604/how-to-open-process-substituted-file-from-php

Test script:
---------------
$ php -d open_basedir= -r 'var_dump(file_get_contents($_SERVER["argv"][1]));' -- <(echo test)

Expected result:
----------------
test

Actual result:
--------------
PHP Warning:  fopen(/dev/fd/63): failed to open stream: No such file or directory in Command line code on line 1
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Jul 19 13:01:25 2018 UTC