From: mark at vectrex dot org dot uk
Operating system: Linux
PHP version: 5.1.2
PHP Bug Type: Streams related
Bug description: stream_filter_append with zlib inflate filter on http stream
crashes
Description:
------------
I'm trying to fetch a gzipped item from a web server and inflate it using
the zlib inflate filter.
This causes a segfault.
Reproduce code:
---------------
<?php
echo "Registered filters: --- \n\n";
print_r(stream_get_filters());
$opts = array(
'http'=>array(
'method'=>"GET",
'header' => "Accept-Encoding:gzip"
)
);
$ctx = stream_context_create($opts);
$url = "http://www.vectrex.org.uk/mark/web/test.txt.gz";
$f = fopen($url, "r", false, $ctx);
echo "appending filter...\n";
stream_filter_append($f, 'zlib.inflate', STREAM_FILTER_READ);
echo "filter appended, getting data....\n";
$data = stream_get_contents($f);
$metadata = stream_get_meta_data($f);
fclose($f);
echo "METADATA: ----- \n\n";
print_r($metadata);
echo "DATA: ----- \n\n";
print $data ;
?>
Expected result:
----------------
The file will be printed uncompressed. This is intended to use the CLI
SAPI.
Actual result:
--------------
Registered filters: ---
Array
(
[0] => string.rot13
[1] => string.toupper
[2] => string.tolower
[3] => string.strip_tags
[4] => convert.*
[5] => convert.iconv.*
[6] => zlib.*
)
appending filter...
Then it crashes with a segfault, stack trace is:
#0 0x0828efb8 in php_stream_bucket_unlink (bucket=0x86bac94,
tsrm_ls=0x859b018)
at /home/mark/unpack/php-5.1.2/main/streams/filter.c:228
#1 0x0828f46d in _php_stream_filter_append (chain=0x86bad74,
filter=0x86b9934,
tsrm_ls=0x859b018) at
/home/mark/unpack/php-5.1.2/main/streams/filter.c:370
#2 0x0826729a in apply_filter_to_stream (append=1, ht=0,
return_value=0x86b8894,
return_value_ptr=0x0, this_ptr=0x0, return_value_used=0,
tsrm_ls=0x859b018)
at /home/mark/unpack/php-5.1.2/ext/standard/streamsfuncs.c:1085
#3 0x0826739c in zif_stream_filter_append (ht=0, return_value=0x0,
return_value_ptr=0x0,
this_ptr=0x0, return_value_used=0, tsrm_ls=0x0)
at /home/mark/unpack/php-5.1.2/ext/standard/streamsfuncs.c:1123
#4 0x082d5fee in zend_do_fcall_common_helper_SPEC
(execute_data=0xbfaa9910, tsrm_ls=0x859b018)
at zend_vm_execute.h:192
#5 0x082d56ec in execute (op_array=0x86b5994, tsrm_ls=0x859b018) at
zend_vm_execute.h:92
#6 0x082bb1fc in zend_execute_scripts (type=8, tsrm_ls=0x859b018,
retval=0x0, file_count=3)
at /home/mark/unpack/php-5.1.2/Zend/zend.c:1101
#7 0x0827a064 in php_execute_script (primary_file=0xbfaabd90,
tsrm_ls=0x859b018)
at /home/mark/unpack/php-5.1.2/main/main.c:1720
#8 0x0832cf73 in main (argc=2, argv=0xbfaabe54)
at /home/mark/unpack/php-5.1.2/sapi/cli/php_cli.c:1077
--
Edit bug report at http://bugs.php.net/?id=36515&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36515&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36515&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36515&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36515&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36515&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36515&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36515&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36515&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36515&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36515&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36515&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36515&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36515&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36515&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36515&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36515&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36515&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36515&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36515&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36515&r=mysqlcfg