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:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yuri dot kanivetsky at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 10:01:32 2024 UTC