mirror of
https://github.com/intel/isa-l.git
synced 2025-12-12 12:56:42 +01:00
shim: improve overconsumption workaround
Fix issue: #369 Signed-off-by: Veronika Karpenko <veronika.karpenko@intel.com>
This commit is contained in:
committed by
Pablo de Lara
parent
b93efe5a43
commit
e6db28bf03
@@ -167,12 +167,9 @@ inflate(z_streamp strm, int flush)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// WORKAROUND: ISA-L over-consumption fix for raw deflate mode
|
// WORKAROUND: ISA-L over-consumption fix for raw deflate mode
|
||||||
// When ISA-L reaches BLOCK_FINISH in raw deflate mode, it sometimes over-consumes
|
if ((isal_strm_inflate->block_state == ISAL_BLOCK_FINISH ||
|
||||||
// input data that should be left for upper-layer protocol handling (like gzip trailer).
|
isal_strm_inflate->block_state == ISAL_BLOCK_INPUT_DONE) &&
|
||||||
// 8 bytes have to remain for the gzip trailer.
|
(isal_strm_inflate->crc_flag == 0) && // raw deflate
|
||||||
// Only apply this fix once per stream, when we're truly at the end.
|
|
||||||
if (isal_strm_inflate->block_state == ISAL_BLOCK_FINISH &&
|
|
||||||
isal_strm_inflate->crc_flag == 0 && // raw deflate mode
|
|
||||||
s->trailer_overconsumption_fixed == 0 && // hasn't been applied yet
|
s->trailer_overconsumption_fixed == 0 && // hasn't been applied yet
|
||||||
decomp == ISAL_DECOMP_OK && // successful decompression
|
decomp == ISAL_DECOMP_OK && // successful decompression
|
||||||
isal_strm_inflate->avail_in < 8 && isal_strm_inflate->avail_in > 0) {
|
isal_strm_inflate->avail_in < 8 && isal_strm_inflate->avail_in > 0) {
|
||||||
@@ -224,22 +221,10 @@ inflate(z_streamp strm, int flush)
|
|||||||
|
|
||||||
if (decomp == ISAL_DECOMP_OK) {
|
if (decomp == ISAL_DECOMP_OK) {
|
||||||
if (isal_strm_inflate->block_state == ISAL_BLOCK_FINISH) {
|
if (isal_strm_inflate->block_state == ISAL_BLOCK_FINISH) {
|
||||||
// ISA-L has finished processing the deflate stream AND any format-specific
|
// ISA-L has finished processing the deflate stream including trailer
|
||||||
// trailers
|
// validation
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
strm->msg = "ok";
|
strm->msg = "ok";
|
||||||
} else if (strm->avail_out == 0) {
|
|
||||||
// Output buffer is full, but stream may not be complete
|
|
||||||
ret = Z_OK;
|
|
||||||
} else if (strm->avail_in == 0) {
|
|
||||||
// No more input available
|
|
||||||
if (isal_strm_inflate->block_state == ISAL_BLOCK_FINISH) {
|
|
||||||
// Stream is actually complete - ISA-L has reached final state
|
|
||||||
ret = Z_STREAM_END;
|
|
||||||
} else {
|
|
||||||
// ISA-L still needs more input to finish processing
|
|
||||||
ret = Z_OK;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Still processing, continue
|
// Still processing, continue
|
||||||
ret = Z_OK;
|
ret = Z_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user