summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2022-09-17 15:32:29 +0200
committerHans Kristian Rosbach <hk-github@circlestorm.org>2023-03-17 21:27:56 +0100
commita95801dc9d166954165a98089c7b34658c7630ba (patch)
treec5d166c0fe3f404a3a6552168bcd7432a0d0ed29
parent44a4d00f353dcbcc2ffd2ec84922d1b09ec2a588 (diff)
IBM zSystems DFLTCC: Fix updating strm.adler
inflate() does not update strm.adler with DFLTCC. deflate() updates strm.adler even for raw streams. Fix by adding wrap checks.
-rw-r--r--arch/s390/dfltcc_deflate.c10
-rw-r--r--arch/s390/dfltcc_inflate.c8
2 files changed, 13 insertions, 5 deletions
diff --git a/arch/s390/dfltcc_deflate.c b/arch/s390/dfltcc_deflate.c
index e3b53ee..9ecc6ba 100644
--- a/arch/s390/dfltcc_deflate.c
+++ b/arch/s390/dfltcc_deflate.c
@@ -210,7 +210,10 @@ again:
*strm->next_out = (unsigned char)state->bi_buf;
/* Honor history and check value */
param->nt = 0;
- param->cv = state->wrap == 2 ? ZSWAP32(strm->adler) : strm->adler;
+ if (state->wrap == 1)
+ param->cv = strm->adler;
+ else if (state->wrap == 2)
+ param->cv = ZSWAP32(strm->adler);
/* When opening a block, choose a Huffman-Table Type */
if (!param->bcf) {
@@ -241,7 +244,10 @@ again:
state->bi_buf = 0; /* Avoid accessing next_out */
else
state->bi_buf = *strm->next_out & ((1 << state->bi_valid) - 1);
- strm->adler = state->wrap == 2 ? ZSWAP32(param->cv) : param->cv;
+ if (state->wrap == 1)
+ strm->adler = param->cv;
+ else if (state->wrap == 2)
+ strm->adler = ZSWAP32(param->cv);
/* Unmask the input data */
strm->avail_in += masked_avail_in;
diff --git a/arch/s390/dfltcc_inflate.c b/arch/s390/dfltcc_inflate.c
index 2535064..801e547 100644
--- a/arch/s390/dfltcc_inflate.c
+++ b/arch/s390/dfltcc_inflate.c
@@ -81,13 +81,14 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush
}
/* Translate stream to parameter block */
- param->cvt = state->flags ? CVT_CRC32 : CVT_ADLER32;
+ param->cvt = ((state->wrap & 4) && state->flags) ? CVT_CRC32 : CVT_ADLER32;
param->sbb = state->bits;
param->hl = state->whave; /* Software and hardware history formats match */
param->ho = (state->wnext - state->whave) & ((1 << HB_BITS) - 1);
if (param->hl)
param->nt = 0; /* Honor history for the first block */
- param->cv = state->flags ? ZSWAP32(state->check) : state->check;
+ if (state->wrap & 4)
+ param->cv = state->flags ? ZSWAP32(state->check) : state->check;
/* Inflate */
do {
@@ -100,7 +101,8 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush
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;
+ if (state->wrap & 4)
+ 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;