This commit is contained in:
twinaphex 2020-07-03 18:58:55 +02:00
parent 85d3a3723e
commit 9aa27010b8
2 changed files with 12 additions and 25 deletions

12
deps/libz/inflate.c vendored
View File

@ -276,7 +276,7 @@ int inflatePrime(z_streamp strm, int bits, int value)
return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
state->hold += value << state->bits;
state->hold += (unsigned)value << state->bits;
state->bits += bits;
return Z_OK;
@ -603,6 +603,8 @@ int inflate(z_streamp strm, int flush)
NEEDBITS(16);
#ifdef GUNZIP
if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
if (state->wbits == 0)
state->wbits = 15;
state->check = crc32(0L, Z_NULL, 0);
CRC2(state->check, hold);
INITBITS();
@ -629,8 +631,8 @@ int inflate(z_streamp strm, int flush)
DROPBITS(4);
len = BITS(4) + 8;
if (state->wbits == 0)
state->wbits = len;
else if (len > state->wbits) {
state->wbits = len;
if (len > 15 || len > state->wbits) {
strm->msg = (char *)"invalid window size";
state->mode = BAD;
break;
@ -1484,10 +1486,10 @@ long inflateMark(z_streamp strm)
if ( strm == Z_NULL ||
strm->state == Z_NULL)
return -1L << 16;
return -(1L << 16);
state = (struct inflate_state FAR *)strm->state;
return ((long)(state->back) << 16) +
return (long)(((unsigned long)((long)state->back)) << 16) +
(state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0));
}

25
deps/libz/trees.c vendored
View File

@ -103,8 +103,6 @@ static int detect_data_type (deflate_state *s);
static unsigned bi_reverse (unsigned value, int length);
static void bi_windup (deflate_state *s);
static void bi_flush (deflate_state *s);
static void copy_block (deflate_state *s, charf *buf, unsigned len,
int header);
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */
@ -595,7 +593,11 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
{
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
bi_windup(s); /* align on byte boundary */
put_short(s, (ush)stored_len);
put_short(s, (ush)~stored_len);
memcpy(s->pending_buf + s->pending, buf, stored_len);
s->pending += stored_len;
}
/* ===========================================================================
@ -874,20 +876,3 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len,
s->bi_buf = 0;
s->bi_valid = 0;
}
/* ===========================================================================
* Copy a stored block, storing first the length and its
* one's complement if requested.
*/
static void copy_block(deflate_state *s, charf *buf, unsigned len, int header)
{
bi_windup(s); /* align on byte boundary */
if (header) {
put_short(s, (ush)len);
put_short(s, (ush)~len);
}
while (len--) {
put_byte(s, *buf++);
}
}