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:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC