Skip to content

Commit 9f652bc

Browse files
committed
Additional upstream fixes for loss of data warnings and errors.
1 parent 503704f commit 9f652bc

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/native/external/zlib-ng/arch/generic/crc32_braid_c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ Z_INTERNAL uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, size_t
192192
#endif
193193
#endif
194194
words += N;
195-
c = ZSWAPWORD(comb);
195+
Assert(comb <= UINT32_MAX, "comb should fit in uint32_t");
196+
c = (uint32_t)ZSWAPWORD(comb);
196197

197198
/* Update the pointer to the remaining bytes to process. */
198199
buf = (const unsigned char *)words;

src/native/external/zlib-ng/deflate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Z_INTERNAL deflate_allocs* alloc_deflate(PREFIX3(stream) *strm, int windowBits,
204204

205205
/* Define sizes */
206206
int window_size = DEFLATE_ADJUST_WINDOW_SIZE((1 << windowBits) * 2);
207-
int prev_size = (1 << windowBits) * sizeof(Pos);
207+
int prev_size = (1 << windowBits) * (int)sizeof(Pos);
208208
int head_size = HASH_SIZE * sizeof(Pos);
209209
int pending_size = lit_bufsize * LIT_BUFS;
210210
int state_size = sizeof(deflate_state);

src/native/external/zlib-ng/deflate_p.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t le
7878
/* dist: distance of matched string */
7979
/* len: match length-STD_MIN_MATCH */
8080
#ifdef LIT_MEM
81-
s->d_buf[s->sym_next] = dist;
82-
s->l_buf[s->sym_next++] = len;
81+
Assert(dist <= UINT16_MAX, "dist should fit in uint16_t");
82+
Assert(len <= UCHAR_MAX, "len should fit in unsigned char");
83+
s->d_buf[s->sym_next] = (uint16_t)dist;
84+
s->l_buf[s->sym_next++] = (uint8_t)len;
8385
#else
8486
s->sym_buf[s->sym_next++] = (uint8_t)(dist);
8587
s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8);

src/native/external/zlib-ng/deflate_rle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) {
6060
if (match_len >= STD_MIN_MATCH) {
6161
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
6262
Assert(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t");
63-
check_match(s, (Pos)s->strstart, (Pos)s->strstart - 1, match_len);
63+
check_match(s, (Pos)s->strstart, (Pos)(s->strstart - 1), match_len);
6464

6565
bflush = zng_tr_tally_dist(s, 1, match_len - STD_MIN_MATCH);
6666

0 commit comments

Comments
 (0)