From 49e3329729de5b57e90057ea63e9a74141356823 Mon Sep 17 00:00:00 2001 From: Roy Oursler Date: Tue, 31 Jul 2018 19:51:22 -0400 Subject: [PATCH] igzip: Fix Stateless Full Flush type0 block bugs Prevent type 0 block in stateless full flush from attempting to write a trailer when it not the end of the stream and fix the values of block_start and block_end. Change-Id: Ia8beac20fc244b1b3e5690cbc15d4d4bb8ada68e Signed-off-by: Roy Oursler --- igzip/igzip.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/igzip/igzip.c b/igzip/igzip.c index 7bed8cf..c7b9ac0 100644 --- a/igzip/igzip.c +++ b/igzip/igzip.c @@ -1316,10 +1316,10 @@ int isal_deflate_stateless(struct isal_zstream *stream) stream->next_in = next_in + avail_in; stream->avail_in = 0; - stream->total_in = total_in + avail_in; + stream->total_in = avail_in; - state->block_next = 0; - state->block_end = avail_in; + state->block_next = stream->total_in - avail_in; + state->block_end = stream->total_in; stream->next_out = next_out; stream->avail_out = avail_out; @@ -1337,12 +1337,16 @@ int isal_deflate_stateless(struct isal_zstream *stream) write_stored_block(stream); + stream->total_in = total_in + avail_in; + if (stream->gzip_flag) { stream->internal_state.crc = 0; update_checksum(stream, next_in, avail_in); } - write_trailer(stream); + if (stream->end_of_stream) + write_trailer(stream); + return COMP_OK; }