Bug #61665 [Com]: include on stream wrapper results in wsod
Edit report at https://bugs.php.net/bug.php?id=61665&edit=1
ID: 61665
Comment by: dave dot qt080 at davehw dot dircon dot co dot uk
Reported by: btmash at gmail dot com
Summary: include on stream wrapper results in wsod
Status: No Feedback
Type: Bug
Package: Streams related
Operating System: Ubuntu 10.04
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
The following script works fine on 5.3.4 but fails with this bug on 5.3.29.
I have attached the script together with the output from each of these PHP versions.
<?
/**
* Stream wrapper class that enables contents of dataContainer::$streamedData variable to be
'included'
*/
class EvaleratorStream {
var $position=0;
public function stream_open($path, $mode, $options, &$opened_path)
{
echo '** stream_open called<BR/>';
$this->position = 0;
return true;
}
public function stream_read($count)
{
echo '** stream_read called<BR/>';
$ret = substr(dataContainer::$streamedData,$this->position,$count);
$this->position += strlen($ret);
return $ret;
}
public function stream_write($data)
{ //Not implemented
echo '** stream_write called<BR/>';
return strlen($data);
}
public function stream_tell()
{
echo '** stream_tell called<BR/>';
return $this->position;
}
public function stream_eof()
{
echo '** stream_eof called<BR/>';
return $this->position>=strlen(dataContainer::$streamedData);
}
public function stream_seek($offset, $whence)
{
echo '** stream_seek called<BR/>';
switch ($whence)
{
case SEEK_SET:
if ($offset<strlen(dataContainer::$streamedData) && $offset>=0)
{
$this->position = $offset;
return true;
}
return false;
case SEEK_CUR:
if ($offset >= 0)
{
$this->position += $offset;
return true;
}
return false;
case SEEK_END:
if (strlen(dataContainer::$streamedData) + $offset>=0)
{
$this->position= strlen(dataContainer::$streamedData)+$offset;
return true;
}
return false;
default:
return false;
}
}
public function stream_metadata($path, $option, $var)
{
echo '** stream_metadata called<BR/>';
if($option==STREAM_META_TOUCH)
return true;
return false;
}
public function stream_stat()
{
echo '** stream_stat called<BR/>';
return array(7=>strlen(dataContainer::$streamedData),
'size'=>strlen(dataContainer::$streamedData));
}
public function stream_close()
{
echo '** stream_close called<BR/>';
}
//The following functions should not be required, but are included
// with echo's, just so we can see if they get called
public function dir_closedir()
{
echo '** dir_closedir called<BR/>';
return true;
}
public function dir_opendir($path,$options)
{
echo '** dir_opendir called<BR/>';
return true;
}
public function dir_readdir()
{
echo '** dir_readdir called<BR/>';
return '';
}
public function dir_rewinddir()
{
echo '** dir_rewinddir called<BR/>';
return true;
}
public function mkdir($path,$mode,$options)
{
echo '** mkdir called<BR/>';
return true;
}
public function rename($path_from,$path_to)
{
echo '** rename called<BR/>';
return true;
}
public function rmdir($path,$options)
{
echo '** rmdir called<BR/>';
return true;
}
public function stream_cast($cast_as)
{
echo '** stream_cast called<BR/>';
return false;
}
public function stream_flush()
{
echo '** stream_flush called<BR/>';
return true;
}
public function stream_lock($operation)
{
echo '** stream_lock called<BR/>';
return true;
}
public function stream_set_option ($option,$arg1,$arg2)
{
echo '** stream_set_option called<BR/>';
return true;
}
public function stream_truncate ($new_size)
{
echo '** stream_truncate called<BR/>';
return true;
}
public function unlink ($path)
{
echo '** unlink called<BR/>';
return true;
}
public function url_stat($path,$flags)
{
echo '** url_stat called<BR/>';
return array();
}
}
class dataContainer
{
public static $streamedData;
}
error_reporting(E_ALL);
if (!stream_wrapper_register("var", "EvaleratorStream"))
trigger_error("Unable to register stream wrapper", E_USER_ERROR);
echo 'registered ok<BR/>';
//Initialise the streamed data with a simple script containing
// a PHP echo statement
dataContainer::$streamedData='<?echo "Yay - Executing streamed
script!<BR/>";?>';
echo 'data stored<BR/>';
//Try to read and print the stream
$file=fopen("var://streamedData",'r');
if ($file===false)
{
echo 'file open failed';
exit;
}
echo 'stream was opened ok<BR/>';
$data=fgets($file);
echo 'stream data='.htmlspecialchars($data).'<BR/>';
fclose($file);
echo 'stream closed ok<BR/>';
//Try to include the streamed script so it gets executed
// At this point, PHP 5.3.4 executes the script correctly and the 'Yay' message is echoed
// In contrast, PHP 5.3.29 dies with nothing at all displayed after the 'stream closed
ok'
include "var://streamedData";
echo 'end<BR/>';
?>
OUTPUT FROM PHP 5.3.4:
registered ok
data written
** stream_open called
stream was opened ok
** stream_read called
** stream_eof called
stream data=<?echo "Yay - Executing streamed script!<BR/>";?>
** stream_flush called
** stream_close called
stream closed ok
** stream_open called
** stream_stat called
** stream_stat called
** stream_read called
** stream_eof called
** stream_read called
** stream_eof called
** stream_flush called
** stream_close called
Yay - Executing streamed script!
end
OUTPUT FROM PHP 5.3.29:
registered ok
data written
** stream_open called
stream was opened ok
** stream_read called
** stream_eof called
stream data=<?echo "Yay - Executing streamed script!<BR/>";?>
** stream_flush called
** stream_close called
stream closed ok
Previous Comments:
------------------------------------------------------------------------
[2013-02-18 00:35:47] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2012-06-28 00:56:28] pollita@php.net
Hi, could you paste the wrapper code again? That link is invalid (the content
hosting site went down). Thanks!
------------------------------------------------------------------------
[2012-04-19 08:08:15] btmash at gmail dot com
I'm setting it back to open since I've provided feedback.
------------------------------------------------------------------------
[2012-04-09 23:29:13] btmash at gmail dot com
I've pasted a version of the class at http://paste.pocoo.org/show/578721/ since it is
longer than 20 lines.
Please note that a large chunk of this is the drupal stream wrapper interface and at the bottom is
the stream class that I implemented 'MyLocalStreamWrapper' which returns back the
directory it is currently in. I perform an include to a info.php file which consists of:
"
<?php
phpinfo();
"
I tested this out on PHP 5.3.8 and it worked. When I tested this on 5.3.10, it failed.
------------------------------------------------------------------------
[2012-04-09 22:12:44] cataphract@php.net
Please include the code of the stream wrapper, otherwise we can't reproduce this problem. In
particular, the implementation of stream_open would be very important (but please include
everything).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=61665
--
Edit this bug report at https://bugs.php.net/bug.php?id=61665&edit=1
Thread (8 messages)