php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34501 PHP crashes when you use include for user defined stream wrapper
Submitted: 2005-09-14 20:37 UTC Modified: 2005-09-15 09:54 UTC
From: dmitry dot poltaryonok at gmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.0.5 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2005-09-14 20:37 UTC] dmitry dot poltaryonok at gmail dot com
Description:
------------
After you register custom wrapper PHP crashes during inclusion of the file using this wrapper.

Reproduce code:
---------------
<?
define('suAPI', 'mywrap://api.su/api/', true);
class mywrap
{
	function stream_open ( $path, $mode, $options, &$opened_path )
	{
		return true;
	}
	function stream_read ( $count )
	{
		return '<? echo \'test\';?>';
	}
}
stream_wrapper_register('mywrap', 'mywrap');
include(suAPI.'config/config.php');
?>

Expected result:
----------------
I expect to see "test" string echoed from included code. included code returned by stream_read()

Actual result:
--------------
Windows displays that CLI PHP application crashed (or that Apache is crashed).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-14 20:48 UTC] dmitry dot poltaryonok at gmail dot com
Crash is right after call to stream_open
 [2005-09-14 22:32 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

And fix your script. The wrapper class is incomplete.

 [2005-09-15 09:23 UTC] dmitry dot poltaryonok at gmail dot com
My actual wrapper is complete (contains all functions)
 [2005-09-15 09:30 UTC] tony2001@php.net
Then provide your actual reproduce code, not the one that doesn't work at all.
 [2005-09-15 09:31 UTC] sniper@php.net
No it isn't. I get an error while running your script about not having implemented stream_eof(). Try the snapshot.

 [2005-09-15 09:45 UTC] dmitry dot poltaryonok at gmail dot com
Ok with the latest versions of PHP 5 my actual wrapper works (not the fragment I posted)
 [2005-09-15 09:47 UTC] dmitry dot poltaryonok at gmail dot com
Sorry for posting code which will get the error stream_eof is not implement or stream_stat is not implemented, because I wasn't able to see this errors because php just crashed.
 [2005-09-15 09:54 UTC] sniper@php.net
And the crash was caused because this incomplete wrapper ends up in an endless loop, eats all memory and finally crashes.
It's not really PHP bug, just user error.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 10:01:32 2025 UTC