--- embedaddon/php/ext/zlib/zlib_filter.c 2012/02/21 23:48:05 1.1 +++ embedaddon/php/ext/zlib/zlib_filter.c 2014/06/15 20:04:01 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zlib_filter.c,v 1.1 2012/02/21 23:48:05 misho Exp $ */ +/* $Id: zlib_filter.c,v 1.1.1.4 2014/06/15 20:04:01 misho Exp $ */ #include "php.h" #include "php_zlib.h" @@ -80,9 +80,12 @@ static php_stream_filter_status_t php_zlib_inflate_fil while (buckets_in->head) { size_t bin = 0, desired; + bucket = buckets_in->head; + bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC); - while (bin < bucket->buflen) { + while (bin < (unsigned int) bucket->buflen) { + if (data->finished) { consumed += bucket->buflen; break; @@ -110,7 +113,6 @@ static php_stream_filter_status_t php_zlib_inflate_fil 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) { @@ -126,7 +128,9 @@ static php_stream_filter_status_t php_zlib_inflate_fil php_stream_bucket_delref(bucket TSRMLS_CC); return PSFS_PASS_ON; } + } + consumed += bucket->buflen; php_stream_bucket_delref(bucket TSRMLS_CC); } @@ -205,9 +209,11 @@ static php_stream_filter_status_t php_zlib_deflate_fil while (buckets_in->head) { size_t bin = 0, desired; - bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC); + bucket = buckets_in->head; - while (bin < bucket->buflen) { + bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC); + + while (bin < (unsigned int) bucket->buflen) { desired = bucket->buflen - bin; if (desired > data->inbuf_len) { desired = data->inbuf_len; @@ -224,7 +230,6 @@ static php_stream_filter_status_t php_zlib_deflate_fil 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) { @@ -238,6 +243,7 @@ static php_stream_filter_status_t php_zlib_deflate_fil exit_status = PSFS_PASS_ON; } } + consumed += bucket->buflen; php_stream_bucket_delref(bucket TSRMLS_CC); } @@ -261,6 +267,7 @@ static php_stream_filter_status_t php_zlib_deflate_fil if (bytes_consumed) { *bytes_consumed = consumed; } + return exit_status; } @@ -294,7 +301,7 @@ static php_stream_filter *php_zlib_filter_create(const /* Create this filter */ data = pecalloc(1, sizeof(php_zlib_filter_data), persistent); if (!data) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", sizeof(php_zlib_filter_data)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data)); return NULL; } @@ -306,14 +313,14 @@ static php_stream_filter *php_zlib_filter_create(const data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048; data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent); if (!data->inbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->inbuf_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len); pefree(data, persistent); return NULL; } data->strm.avail_in = 0; data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent); if (!data->outbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->outbuf_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len); pefree(data->inbuf, persistent); pefree(data, persistent); return NULL; @@ -412,7 +419,7 @@ factory_setlevel: } break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored."); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored"); } } status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0);