php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46076 Php registered streams: no streams registered with session.so
Submitted: 2008-09-14 13:12 UTC Modified: 2010-12-20 12:37 UTC
From: sl9 at gmx dot net Assigned:
Status: Not a bug Package: Dynamic loading
PHP Version: 5.2.6 OS: Linux 2.6, ArchLinux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sl9 at gmx dot net
New email:
PHP Version: OS:

 

 [2008-09-14 13:12 UTC] sl9 at gmx dot net
Description:
------------
Hi,

I compiled php 5.2.6 with the suhosin patch. I have some issues 
relating to the session.so and 
simplexml.so modules, which also affects zlib.so and bz2.so.
I have traced behavior, which doesn't let me include or read files, 
to the registered php 
streams. Which is easily obtainable from the phpinfo() output.
Consider the lines below and their output. The registered php streams 
string gets mangled by 
including different modules. The resulting string seems to be 
semantically incorrect.

I've tried a lot of different configure lines, changing extensions, 
with or without the suhosin 
patch. Didn't seem to change results except when I used --enable-
simplexml instead of --enable-
simplexml=shared. So compiling it in or loading it via php.ini is a 
workaround.





Reproduce code:
---------------
The configure string I used contains all the options I could find (sorry about that).
--enable-libxml=shared
	--without-libxml-dir
--with-openssl=shared
	--with-kerberos=shared
--with-pcre-regex=/usr
--with-zlib=shared
	--without-zlib-dir
--disable-bcmath
--with-bz2=shared
--enable-calendar=shared
--enable-ctype
--with-curl=shared
	--without-curl-wrappers
--disable-dba
	--without-qdbm
	--without-gdbm
	--without-ndbm
	--without-db4
	--without-db3
	--without-db2
	--without-db1
	--without-dbm
	--without-cdb
	--disable-inifile
	--disable-flatfile
--disable-dbase
--enable-dom
	--without-libxml-dir
--enable-exif=shared
--without-fbsql
--without-fdftk
--enable-filter
	--without-pcre-dir
--enable-ftp=shared
	--without-openssl-dir
--with-gd=shared
	--with-jpeg-dir=shared,/usr
	--with-png-dir=shared,/usr
	--without-zlib-dir
	--without-xmp-dir
	--with-ttf=shared
	--without-freetype-dir
	--without-t1lib
	--enable-gd-native-ttf
	--disable-gd-jis-conv
--without-gettext
--without-gmp
--enable-hash=shared
--with-iconv=shared
--without-imap
	--with-kerberos
	--with-imap-ssl=shared
--without-interbase
--enable-json=shared
--without-ldap
	--without-ldap-sasl
--disable-mbstring
	--disable-mbregex
	--disable-mbregex-backtrack
	--without-libmbfl
--with-mcrypt=shared
--with-mhash=shared
--with-mime-magic=shared
--without-ming
--without-msql
--without-mssql
--with-mysql=shared
	--with-mysql-sock=/tmp/mysql.sock
	--without-zlib-dir
--with-mysqli=shared
	--disable-embedded-mysqli
--without-ncurses
--without-oci8
--without-adabas
--without-sapdb
--without-solid
--without-ibm-db2
--without-ODBCRouter
--without-empress
--without-empress-bcs
--without-birdstep
--without-custom-odbc
--without-iodbc
--without-esoob
--without-unixODBC
--without-dbmaker
--enable-pcntl
--enable-pdo=shared
	--without-pdo-dblib
	--without-pdo-firebird
	--with-pdo-mysql=shared
	--without-zlib-dir
	--without-pdo-oci
	--without-pdo-odbc
	--without-pdo-pgsql
	--with-pdo-sqlite=shared
--without-pgsql
--enable-posix=shared
--without-pspell
--without-libedit
--with-readline=shared
--without-recode
--enable-reflection
--enable-session=shared
	--without-mm
--enable-shmop=shared
--enable-simplexml=shared
	--without-libxml-dir
--without-snmp
	--without-openssl-dir
	--without-ucd-snmp-hack
--enable-soap=shared
	--without-libxml-dir
--enable-sockets=shared
--enable-spl=shared
--with-sqlite=shared
	--enable-sqlite-utf8=shared
--with-regex=php
--without-sybase
--without-sybase-ct
--enable-sysvmsg=shared
--enable-sysvsem=shared
--enable-sysvshm=shared
--without-tidy
--disable-tokenizer
--disable-wddx
	--without-libxml-dir
	--without-libexpat-dir
--enable-xml
	--without-libxml-dir
	--without-libexpat-dir
--enable-xmlreader=shared
	--without-libxml-dir
--without-xmlrpc
	--without-libxml-dir
	--without-libexpat-dir
	--without-iconv-dir
--enable-xmlwriter=shared
	--without-libxml-dir
--with-xsl=shared
--enable-zip=shared
	--without-zlib-dir

I have ran my test code on different configurations, but the issues seem to be directly related to the php registered streams string. Which is easier to capture, post and relate to behavior, which is done in the 'actual result' section.

Example 1:
php.ini: (no extensions loaded)
phpinfo()'s registered php streams: "php, file, data, http, ftp"
Note: local file opening/reading (fopen, fread) and inclusion (include, require, require_once) is working fully.

Example 2:
php.ini:
extension=bz2.so
extension=zlib.so

phpinfo()'s registered php streams: "php, file, data, http, ftp"
Note: the two compression streams are not registered and don't work.

Example 3:
php.ini:
extension=bz2.so
extension=session.so
extension=zlib.so

phpinfo()'s registered php streams: "no streams registered"
Note: at this point files can be opened but cannot be read, more on this in the 'actual result' section.

Example 4:
php.ini:
extension=session.so

phpinfo()'s registered php streams: "no streams registered"
Note: the session module seems to be the culprit.

Example 5:
php.ini:
extension=simplexml.so

phpinfo()'s registered php streams: "php, file, data, http, ftp"
Note: simplexml doesn't seem to change anything.

Example 6:
php.ini:
extension=session.so
extension=simplexml.so

phpinfo()'s registered php streams: "php, file, data, http, ftp"
Note: coupled with the session module simplexml restores the registered streams.

Example 7:
php.ini:
extension=bz2.so
extension=session.so
extension=simplexml.so
extension=zlib.so

phpinfo()'s registered php streams: "compress.bzip2, php, file, data, http, ftp, compress.zlib"
Note: simplexml even enables the two compression streams to be registered.

Example 8:
php.ini:
extension=bz2.so
extension=simplexml.so
extension=zlib.so

phpinfo()'s registered php streams: "php, file, data, http, ftp, compress.bzip2, compress.zlib"
Note: the string's elements have changed position.

Test code:
With the above configurations I've ran the following code.

bugtest.inc.php:
File included.
<?php
function bugtest(){
	echo "Function accessible\n";
}
?>

bugtest.php:
<pre>
<?php

$incResult = include("bugtest.inc.php");

if(!$incResult){
	echo "Include failed.\n";
}else{
	echo "Include succeeded.\n\n";
	if(!function_exists("bugtest")){
		echo "Function 'bugtest' is not defined.\n";
	}else{
		echo "Function 'bugtest' is defined.... invoking:\n";
		bugtest();
	}

	echo "\nCode included was (via fopen):\n";
	$fp = fopen("bugtest.inc.php",'r');
	while(!feof($fp)){
		$readBuffer = fread($fp,128);
		if($readBuffer){
			$readBuffer = str_replace(array('<','>'),	 array('&lt;','&gt;'), $readBuffer);
			echo "Read(".strlen($readBuffer)."):\n".$readBuffer."\n";
		}else{
			echo "Read failed.\n";
		}
	}
	fclose($fp);

	echo "\nCode included was (via file_get_contents):\n";
	$readBuffer = file_get_contents("bugtest.inc.php");
	if($readBuffer){
		$readBuffer = str_replace(array('<','>'),	 array('&lt;','&gt;'), $readBuffer);
		echo "Read(".strlen($readBuffer)."):\n".$readBuffer."\n";
	}else{
		echo "Read failed.\n";
	}

	echo "\nCode included was (via highlight_file):";
	highlight_file("bugtest.inc.php");

	echo "\nGZip compressed text file (via file_get_contents):\n";
	$readBuffer = file_get_contents("compress.zlib://bugtest.gz");
	if($readBuffer){
		echo "Read(".strlen($readBuffer)."):\n".$readBuffer."\n";
	}else{
		echo "Read failed.\n";
	}

	echo "\nBZip2 compressed text file (via file_get_contents):\n";
	$readBuffer = file_get_contents("compress.bzip2://bugtest.bz2");
	if($readBuffer){
		echo "Read(".strlen($readBuffer)."):\n".$readBuffer."\n";
	}else{
		echo "Read failed.\n";
	}
}
?>
</pre>

Expected result:
----------------
Expected results are pretty straight forward, but I could be wrong in 
my assumptions.
When I load no extensions I expect to have enough registered streams 
to use the php core (fopen, 
fread, include, etc.).
When I load the zlib.so module I expect to get an additional 
'compress.zlib' registered stream, which is usable in reading those 
types of streams.
When I load the bzip2.so module I expect to get an additional 
'compress.bzip2' registered stream, 
which is usable in reading those types of streams.
I expect the loading of the session.so module not to affect the 
registered streams string.
I expect the loading of the simplexml.so module not to affect the 
registered streams string.
I don't expect the simplexml.so module to 'fix' the registered 
streams string after the session 
module has corrupted it.
I don't expect the simplexml.so module to 'fix' the registered 
streams string when loading the 
compression modules.




Actual result:
--------------
The results have several different flavors, related to the php 
registered streams string.

Registered streams string: "php, file, data, http, ftp"
Include done: Yes
Function accessible: Yes
Code output: Yes (fopen, file_get_contents, highlight_file)
Compressed output: No, compression stream not registered. (Bzip2, 
Gzip)

Registered streams string: "no streams registered"
Include done: No, but include returns true
Function accessible: No, function not defined
Code output: No
fopen code output: fopen succeeds, but fread appends the following 
error at the end of the 
document.
"Warning: Unknown list entry type in request shutdown (-1) in Unknown 
on line 0"
file_get_contents output: returns false
highlight_file output: empty output (probably also failure when 
reading)
Compressed output: No, compression stream not registered. (Bzip2, 
Gzip)

Registered streams string: "compress.bzip2, php, file, data, http, 
ftp, compress.zlib"
Include done: Yes
Function accessible: Yes
Code output: Yes (fopen, file_get_contents, highlight_file)
Compressed output: Yes (Bzip2, Gzip)

Registered streams string: "php, file, data, http, ftp, 
compress.bzip2, compress.zlib"
Include done: Yes
Function accessible: Yes
Code output: Yes (fopen, file_get_contents, highlight_file)
Compressed output: Yes (Bzip2, Gzip)




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-14 13:56 UTC] sl9 at gmx dot net
Using --disable-spl instead of --enable-spl=shared seems to fix all 
of the above problems. But this could mean, I can't use spl.

Still session.so changes the order of the registered streams string.
 [2008-09-14 14:47 UTC] sl9 at gmx dot net
Changed from "dynamic loading" to "streams related". Seems more 
appropriate.
 [2008-09-15 07:59 UTC] jani@php.net
If you compile core things like session as shared module, you're also giving up on certain functionality. No bug here.
 [2010-12-20 12:37 UTC] jani@php.net
-Package: Tidy +Package: Dynamic loading
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 01:01:31 2024 UTC