From 4bf531b403fdc6d0f2db99ad7fd92fa93bc7fabd Mon Sep 17 00:00:00 2001 From: Veronika Karpenko Date: Thu, 16 Oct 2025 10:11:28 +0000 Subject: [PATCH] shim: add inflateReset Fix issue: #368 Signed-off-by: Veronika Karpenko --- igzip/shim/README.md | 2 +- igzip/shim/shim_inflate.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/igzip/shim/README.md b/igzip/shim/README.md index 20ff2b4..49833a8 100644 --- a/igzip/shim/README.md +++ b/igzip/shim/README.md @@ -71,7 +71,7 @@ For production use, thorough testing in your specific environment is recommended deflate/inflate and related functions - deflateInit, deflateInit2, deflateSetDictionary, deflate, deflateEnd, deflateSetHeader -- inflateInit, inflateInit2, inflateSetDictionary, inflate, inflateEnd +- inflateInit, inflateInit2, inflateSetDictionary, inflate, inflateEnd, inflateReset checksum functions - crc32, adler32 diff --git a/igzip/shim/shim_inflate.c b/igzip/shim/shim_inflate.c index f99d63c..0cba518 100644 --- a/igzip/shim/shim_inflate.c +++ b/igzip/shim/shim_inflate.c @@ -384,3 +384,36 @@ uncompress(uint8_t *dest, unsigned long *dest_len, const uint8_t *source, unsign { return uncompress2(dest, dest_len, source, &source_len); } + +int +inflateReset(z_streamp strm) +{ + if (!strm) { + fprintf(stderr, "Error: z_streamp is NULL\n"); + return Z_STREAM_ERROR; + } + + inflate_state2 *s = (inflate_state2 *) strm->state; + if (!s) { + fprintf(stderr, "Error: inflate_state2 is NULL\n"); + return Z_STREAM_ERROR; + } + + struct inflate_state *isal_strm_inflate = s->isal_strm_inflate; + if (!isal_strm_inflate) { + fprintf(stderr, "Error: isal_strm_inflate is NULL\n"); + return Z_STREAM_ERROR; + } + + // Reset ISA-L inflate state + isal_inflate_reset(isal_strm_inflate); + + strm->total_out = 0; + strm->total_in = 0; + strm->msg = NULL; + + // Reset workaround flag + s->trailer_overconsumption_fixed = 0; + + return Z_OK; +} \ No newline at end of file