diff --git a/src/native/external/zlib-ng/arch/generic/crc32_braid_c.c b/src/native/external/zlib-ng/arch/generic/crc32_braid_c.c index 7d8028f6d70555..f80071042d77c6 100644 --- a/src/native/external/zlib-ng/arch/generic/crc32_braid_c.c +++ b/src/native/external/zlib-ng/arch/generic/crc32_braid_c.c @@ -192,7 +192,8 @@ Z_INTERNAL uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, size_t #endif #endif words += N; - c = ZSWAPWORD(comb); + Assert(comb <= UINT32_MAX, "comb should fit in uint32_t"); + c = (uint32_t)ZSWAPWORD(comb); /* Update the pointer to the remaining bytes to process. */ buf = (const unsigned char *)words; diff --git a/src/native/external/zlib-ng/deflate.c b/src/native/external/zlib-ng/deflate.c index 66b5506a521e5c..eb5ae0aabd5973 100644 --- a/src/native/external/zlib-ng/deflate.c +++ b/src/native/external/zlib-ng/deflate.c @@ -204,7 +204,7 @@ Z_INTERNAL deflate_allocs* alloc_deflate(PREFIX3(stream) *strm, int windowBits, /* Define sizes */ int window_size = DEFLATE_ADJUST_WINDOW_SIZE((1 << windowBits) * 2); - int prev_size = (1 << windowBits) * sizeof(Pos); + int prev_size = (1 << windowBits) * (int)sizeof(Pos); int head_size = HASH_SIZE * sizeof(Pos); int pending_size = lit_bufsize * LIT_BUFS; int state_size = sizeof(deflate_state); diff --git a/src/native/external/zlib-ng/deflate_p.h b/src/native/external/zlib-ng/deflate_p.h index 7c74ebf5ad771a..abcc8b1c7c1255 100644 --- a/src/native/external/zlib-ng/deflate_p.h +++ b/src/native/external/zlib-ng/deflate_p.h @@ -78,8 +78,10 @@ static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t le /* dist: distance of matched string */ /* len: match length-STD_MIN_MATCH */ #ifdef LIT_MEM - s->d_buf[s->sym_next] = dist; - s->l_buf[s->sym_next++] = len; + Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); + Assert(len <= UINT8_MAX, "len should fit in uint8_t"); + s->d_buf[s->sym_next] = (uint16_t)dist; + s->l_buf[s->sym_next++] = (uint8_t)len; #else s->sym_buf[s->sym_next++] = (uint8_t)(dist); s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); diff --git a/src/native/external/zlib-ng/deflate_rle.c b/src/native/external/zlib-ng/deflate_rle.c index 042800058f1ae5..fb17a63c5eb262 100644 --- a/src/native/external/zlib-ng/deflate_rle.c +++ b/src/native/external/zlib-ng/deflate_rle.c @@ -60,7 +60,7 @@ Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) { if (match_len >= STD_MIN_MATCH) { Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t"); Assert(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t"); - check_match(s, (Pos)s->strstart, (Pos)s->strstart - 1, match_len); + check_match(s, (Pos)s->strstart, (Pos)(s->strstart - 1), match_len); bflush = zng_tr_tally_dist(s, 1, match_len - STD_MIN_MATCH);