1
1
Data may remain in zlib internal buffers when inflate() returns Z_OK
and avail_out == 0. In that case, inflate has to be called again.

Also, once all the data has been inflated, it returns Z_BUF_ERROR to
signal that the input buffer has been exhausted.

Until now, the way to detect that a packet payload had been completely
decompressed was to check that no data remained on the input buffer
but that didn't account for the case where data remained on the internal
zlib buffers.

That resulted in packets not being completely decompressed and the
missing data reappearing on the next packet, though the bug was masked
by the buffer allocation algorithm most of the time and only manifested
when transferring highly compressible data.

This patch fixes the zlib usage.

Signed-off-by: Salvador <sfandino@yahoo.com>
Этот коммит содержится в:
Salvador 2013-10-15 11:00:52 +02:00 коммит произвёл Daniel Stenberg
родитель 27f9ac2549
Коммит 55a8b10ad9

@ -259,12 +259,12 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
status = inflate(strm, Z_PARTIAL_FLUSH);
if (status == Z_OK) {
if (! strm->avail_in) {
/* status is OK and input all used so we're done */
if (strm->avail_out > 0)
/* status is OK and the output buffer has not been exhausted so we're done */
break;
}
} else if (status == Z_BUF_ERROR) {
/* This is OK, just drop through to grow the buffer */
/* the input data has been exhausted so we are done */
break;
} else {
/* error state */
LIBSSH2_FREE(session, out);