Bug #64634 [Com]: copy() not working with stream wrappers when open_basedir is set

From: Date: Sat, 20 Apr 2013 18:56:17 +0000
Subject: Bug #64634 [Com]: copy() not working with stream wrappers when open_basedir is set
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178557@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64634&edit=1

 ID:                 64634
 Comment by:         ovidiu at softped dot net
 Reported by:        ovidiu at softped dot com
 Summary:            copy() not working with stream wrappers when
                     open_basedir is set
 Status:             Analyzed
 Type:               Bug
 Package:            Safe Mode/open_basedir
 Operating System:   Windows
 PHP Version:        5.4.14
 Block user comment: N
 Private report:     N

 New Comment:

I was actually using fread / fwrite because I didn't know about 
stream_copy_to_stream() but I will it instead. Thank you.


Previous Comments:
------------------------------------------------------------------------
[2013-04-19 08:31:50] ab@php.net

Looks like the explicit basedir check can be removed in copy() as in the subsequential stack it
calls _php_stream_open_wrapper_ex which would care about it anyway. Though I'm not sure what BC
and security breaches it would introduce. 

@ovidiu what prevents you to use something like stream_copy_to_stream() or alike?

------------------------------------------------------------------------
[2013-04-11 19:14:40] ovidiu at softped dot com

Description:
------------
When open_basedir is set to something other than "no value" the copy function 
fails when trying to read from php://input with the following message:

Warning: copy(): open_basedir restriction in effect. File(php://input) is not 
within the allowed path(s): (d:\server)

However, when trying file_get_contents('php://input') it successfully reads the 
data.

Test script:
---------------
<?php
copy('php://input','destination.txt');
?>

Expected result:
----------------
Expected a new file to be created "destination.txt" with the contents of 
php://input

Actual result:
--------------
Warning: copy(): open_basedir restriction in effect. File(php://input) is not 
within the allowed path(s): (d:\server)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64634&edit=1


Thread (7 messages)

« previous php.bugs (#178557) next »