ID: 40189
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Assigned
Bug Type: Zlib Related
Operating System: kubuntu linux
PHP Version: 5CVS-2007-01-22 (CVS)
-Assigned To:
+Assigned To: pollita
New Comment:
Sara, could you look into this?
Btw, I can see the very same code in ext/bz2.
Previous Comments:
------------------------------------------------------------------------
[2007-01-22 02:25:51] [EMAIL PROTECTED]
Description:
------------
run the test pecl/phar/tests/phar_ctx_001.phpt or
pecl/phar/tests/phar_oo_compressed_001.phpt
and you will see an endless loop. The loop happens in
ext/zlib/zlib_filter.c at line 83:
while (bin < bucket->buflen) {
desired = bucket->buflen - bin;
if (desired > data->inbuf_len) {
desired = data->inbuf_len;
}
memcpy(data->strm.next_in, bucket->buf + bin, desired);
data->strm.avail_in = desired;
status = inflate(&(data->strm), flags &
PSFS_FLAG_FLUSH_CLOSE ?
Z_FINISH : Z_SYNC_FLUSH);
if (status != Z_OK && status != Z_STREAM_END) {
/* Something bad happened */
php_stream_bucket_delref(bucket TSRMLS_CC);
return PSFS_ERR_FATAL;
}
desired -= data->strm.avail_in; /* desired becomes what
we consumed
this round through */
data->strm.next_in = data->inbuf;
data->strm.avail_in = 0;
consumed += desired;
bin += desired;
if (data->strm.avail_out < data->outbuf_len) {
php_stream_bucket *out_bucket;
size_t bucketlen = data->outbuf_len -
data->strm.avail_out;
out_bucket = php_stream_bucket_new(stream,
estrndup(data->outbuf,
bucketlen), bucketlen, 1, 0 TSRMLS_CC);
php_stream_bucket_append(buckets_out,
out_bucket TSRMLS_CC);
data->strm.avail_out = data->outbuf_len;
data->strm.next_out = data->outbuf;
exit_status = PSFS_PASS_ON;
}
}
the loop should exit when desired is set to 0, but doesn't.
The attached patch fixes this issue.
Reproduce code:
---------------
Index: ext/zlib/zlib_filter.c
===================================================================
RCS file: /repository/php-src/ext/zlib/zlib_filter.c,v
retrieving revision 1.6.2.2.2.3
diff -u -r1.6.2.2.2.3 zlib_filter.c
--- ext/zlib/zlib_filter.c 1 Jan 2007 09:36:10 -0000
1.6.2.2.2.3
+++ ext/zlib/zlib_filter.c 22 Jan 2007 02:23:39 -0000
@@ -99,6 +99,10 @@
data->strm.avail_in = 0;
consumed += desired;
bin += desired;
+ if (!desired) {
+ flags |= PSFS_FLAG_FLUSH_CLOSE;
+ break;
+ }
if (data->strm.avail_out < data->outbuf_len) {
php_stream_bucket *out_bucket;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40189&edit=1