From:             [EMAIL PROTECTED]
Operating system: n/a
PHP version:      5.3CVS-2008-09-22 (CVS)
PHP Bug Type:     Streams related
Bug description:  after stream seek, appending stream filter reads incorrect 
data

Description:
------------
appending a stream filter to a stream that has already had data read into
its buffer can cause unfiltered data to be read back in.  This is because
the data is written to writepos, but read from readpos, and so the buffer
should be invalidated (writepos/readpos set to 0) prior to writing back the
filtered data.

This bug affects all PHP versions, and will be fixed in 5.2, 5.3, and 6.0
by me, I have a working patch ready to commit momentarily

This bug was causing ext/phar/tests/zip/badalias.phpt to fail

Reproduce code:
---------------
execute within php5/ext/phar/tests/zip:

<?php
$a = fopen(dirname(__FILE__) . '/files/' . "badalias1.phar.zip", 'rb');
fseek($a, 37); // seek to zip header
$b = fread($a, 30);
fseek($a, 82); // seek to file data
stream_filter_append($a, 'zlib.inflate', STREAM_FILTER_READ);
var_dump(fread($a, 8));
?>


Expected result:
----------------
string(8) "hi/there"


Actual result:
--------------
string(8) "&#65533;&#65533;&#65533;/&#65533;H-J"


-- 
Edit bug report at http://bugs.php.net/?id=46147&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46147&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46147&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46147&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46147&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46147&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46147&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46147&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46147&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46147&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46147&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46147&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46147&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46147&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46147&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46147&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46147&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46147&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46147&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46147&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46147&r=mysqlcfg

Reply via email to