diff options
| -rw-r--r-- | inflate.c | 7 | ||||
| -rw-r--r-- | inflate_p.h | 17 |
2 files changed, 16 insertions, 8 deletions
@@ -502,7 +502,9 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->head->hcrc = (int)((state->flags >> 9) & 1); state->head->done = 1; } - strm->adler = state->check = functable.crc32_fold_reset(&state->crc_fold); + /* compute crc32 checksum if not in raw mode */ + if ((state->wrap & 4) && state->flags) + strm->adler = state->check = functable.crc32_fold_reset(&state->crc_fold); state->mode = TYPE; break; #endif @@ -926,7 +928,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { state->total += out; if (INFLATE_NEED_CHECKSUM(strm) && strm->total_out) { - if (state->flags) + /* compute crc32 final value if not in raw mode */ + if ((state->wrap & 4) && state->flags) strm->adler = state->check = functable.crc32_fold_final(&state->crc_fold); } out = left; diff --git a/inflate_p.h b/inflate_p.h index 464b04fdfe..c5ba13a0c6 100644 --- a/inflate_p.h +++ b/inflate_p.h @@ -158,15 +158,20 @@ static inline void inf_crc_copy(PREFIX3(stream) *strm, unsigned char *const dst, if (!INFLATE_NEED_CHECKSUM(strm)) return; - /* check function to use adler32() for zlib or crc32() for gzip */ + /* compute checksum if not in raw mode */ + if (state->wrap & 4) { + /* check flags to use adler32() for zlib or crc32() for gzip */ #ifdef GUNZIP - if (state->flags) - functable.crc32_fold_copy(&state->crc_fold, dst, src, len); - else + if (state->flags) + functable.crc32_fold_copy(&state->crc_fold, dst, src, len); + else #endif - { + { + memcpy(dst, src, len); + strm->adler = state->check = functable.adler32(state->check, dst, len); + } + } else { memcpy(dst, src, len); - strm->adler = state->check = functable.adler32(state->check, dst, len); } } |
