]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
IBM Z DFLTCC: Fix updating strm.adler with inflate()
authorIlya Leoshkevich <iii@linux.ibm.com>
Sat, 17 Sep 2022 13:32:29 +0000 (15:32 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 26 Sep 2022 18:10:10 +0000 (20:10 +0200)
inflate() does not update strm.adler with DFLTCC.
Add a missing assignment to dfltcc_inflate() to fix this.
Note that deflate() is not affected.
Also add a test to prevent regressions.

arch/s390/dfltcc_inflate.c
test/test_inflate_adler32.cc

index 7a422d97e4a833ed353d80e8fe1e46a9df3202a1..b7ecbe275ce3286b9974fda128ae8a489ae47a73 100644 (file)
@@ -115,7 +115,7 @@ dfltcc_inflate_action Z_INTERNAL PREFIX(dfltcc_inflate)(PREFIX3(streamp) strm, i
     state->bits = param->sbb;
     state->whave = param->hl;
     state->wnext = (param->ho + param->hl) & ((1 << HB_BITS) - 1);
-    state->check = state->flags ? ZSWAP32(param->cv) : param->cv;
+    strm->adler = state->check = state->flags ? ZSWAP32(param->cv) : param->cv;
     if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) {
         /* Report an error if stream is corrupted */
         state->mode = BAD;
index e17cf6b795de41bdfac7b83d3f9eb955d61384e8..fb78bb1bfcc2a97ec0ac46e6e65eb00d8186d461 100644 (file)
@@ -41,6 +41,8 @@ TEST(inflate, adler32) {
     err = PREFIX(inflate)(&strm, Z_NO_FLUSH);
     EXPECT_EQ(err, Z_STREAM_END);
 
+    EXPECT_EQ(strm.adler, 0x6b931030);
+
     err = PREFIX(inflateEnd)(&strm);
     EXPECT_EQ(err, Z_OK);