#46147 [Opn->Asn]: after stream seek, appending stream filter reads incorrect data

From: Date: Mon, 22 Sep 2008 01:23:31 +0000
Subject: #46147 [Opn->Asn]: after stream seek, appending stream filter reads incorrect data
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129162@lists.php.net to get a copy of this message
ID: 46147 Updated by: cellog@php.net Reported By: cellog@php.net -Status: Open +Status: Assigned Bug Type: Streams related Operating System: n/a PHP Version: 5.3CVS-2008-09-22 (CVS) -Assigned To: +Assigned To: cellog Previous Comments: ------------------------------------------------------------------------ [2008-09-22 01:23:21] cellog@php.net 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 this bug report at http://bugs.php.net/?id=46147&edit=1

« previous php.bugs (#129162) next »