|
|
|
@ -642,12 +642,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
if ( |
|
|
|
|
#endif |
|
|
|
|
((BITS(8) << 8) + (hold >> 8)) % 31) { |
|
|
|
|
strm->msg = (char *)"incorrect header check"; |
|
|
|
|
strm->msg = (z_const char *)"incorrect header check"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (BITS(4) != Z_DEFLATED) { |
|
|
|
|
strm->msg = (char *)"unknown compression method"; |
|
|
|
|
strm->msg = (z_const char *)"unknown compression method"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -656,7 +656,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
if (state->wbits == 0) |
|
|
|
|
state->wbits = len; |
|
|
|
|
if (len > 15 || len > state->wbits) { |
|
|
|
|
strm->msg = (char *)"invalid window size"; |
|
|
|
|
strm->msg = (z_const char *)"invalid window size"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -672,12 +672,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
NEEDBITS(16); |
|
|
|
|
state->flags = (int)(hold); |
|
|
|
|
if ((state->flags & 0xff) != Z_DEFLATED) { |
|
|
|
|
strm->msg = (char *)"unknown compression method"; |
|
|
|
|
strm->msg = (z_const char *)"unknown compression method"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (state->flags & 0xe000) { |
|
|
|
|
strm->msg = (char *)"unknown header flags set"; |
|
|
|
|
strm->msg = (z_const char *)"unknown header flags set"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -793,7 +793,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
if (state->flags & 0x0200) { |
|
|
|
|
NEEDBITS(16); |
|
|
|
|
if ((state->wrap & 4) && hold != (state->check & 0xffff)) { |
|
|
|
|
strm->msg = (char *)"header crc mismatch"; |
|
|
|
|
strm->msg = (z_const char *)"header crc mismatch"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -855,7 +855,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
state->mode = TABLE; |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
strm->msg = (char *)"invalid block type"; |
|
|
|
|
strm->msg = (z_const char *)"invalid block type"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
} |
|
|
|
|
DROPBITS(2); |
|
|
|
@ -864,7 +864,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
BYTEBITS(); /* go to byte boundary */ |
|
|
|
|
NEEDBITS(32); |
|
|
|
|
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { |
|
|
|
|
strm->msg = (char *)"invalid stored block lengths"; |
|
|
|
|
strm->msg = (z_const char *)"invalid stored block lengths"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -905,7 +905,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
DROPBITS(4); |
|
|
|
|
#ifndef PKZIP_BUG_WORKAROUND |
|
|
|
|
if (state->nlen > 286 || state->ndist > 30) { |
|
|
|
|
strm->msg = (char *)"too many length or distance symbols"; |
|
|
|
|
strm->msg = (z_const char *)"too many length or distance symbols"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -928,7 +928,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
ret = inflate_table(CODES, state->lens, 19, &(state->next), |
|
|
|
|
&(state->lenbits), state->work); |
|
|
|
|
if (ret) { |
|
|
|
|
strm->msg = (char *)"invalid code lengths set"; |
|
|
|
|
strm->msg = (z_const char *)"invalid code lengths set"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -952,7 +952,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
NEEDBITS(here.bits + 2); |
|
|
|
|
DROPBITS(here.bits); |
|
|
|
|
if (state->have == 0) { |
|
|
|
|
strm->msg = (char *)"invalid bit length repeat"; |
|
|
|
|
strm->msg = (z_const char *)"invalid bit length repeat"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -975,7 +975,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
DROPBITS(7); |
|
|
|
|
} |
|
|
|
|
if (state->have + copy > state->nlen + state->ndist) { |
|
|
|
|
strm->msg = (char *)"invalid bit length repeat"; |
|
|
|
|
strm->msg = (z_const char *)"invalid bit length repeat"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -989,7 +989,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
|
|
|
|
|
/* check for end-of-block code (better have one) */ |
|
|
|
|
if (state->lens[256] == 0) { |
|
|
|
|
strm->msg = (char *)"invalid code -- missing end-of-block"; |
|
|
|
|
strm->msg = (z_const char *)"invalid code -- missing end-of-block"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1003,7 +1003,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), |
|
|
|
|
&(state->lenbits), state->work); |
|
|
|
|
if (ret) { |
|
|
|
|
strm->msg = (char *)"invalid literal/lengths set"; |
|
|
|
|
strm->msg = (z_const char *)"invalid literal/lengths set"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1012,7 +1012,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, |
|
|
|
|
&(state->next), &(state->distbits), state->work); |
|
|
|
|
if (ret) { |
|
|
|
|
strm->msg = (char *)"invalid distances set"; |
|
|
|
|
strm->msg = (z_const char *)"invalid distances set"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1066,7 +1066,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (here.op & 64) { |
|
|
|
|
strm->msg = (char *)"invalid literal/length code"; |
|
|
|
|
strm->msg = (z_const char *)"invalid literal/length code"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1104,7 +1104,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
DROPBITS(here.bits); |
|
|
|
|
state->back += here.bits; |
|
|
|
|
if (here.op & 64) { |
|
|
|
|
strm->msg = (char *)"invalid distance code"; |
|
|
|
|
strm->msg = (z_const char *)"invalid distance code"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1121,7 +1121,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
} |
|
|
|
|
#ifdef INFLATE_STRICT |
|
|
|
|
if (state->offset > state->dmax) { |
|
|
|
|
strm->msg = (char *)"invalid distance too far back"; |
|
|
|
|
strm->msg = (z_const char *)"invalid distance too far back"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1136,7 +1136,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
copy = state->offset - copy; |
|
|
|
|
if (copy > state->whave) { |
|
|
|
|
if (state->sane) { |
|
|
|
|
strm->msg = (char *)"invalid distance too far back"; |
|
|
|
|
strm->msg = (z_const char *)"invalid distance too far back"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1195,7 +1195,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
state->flags ? hold : |
|
|
|
|
#endif |
|
|
|
|
ZSWAP32(hold)) != state->check) { |
|
|
|
|
strm->msg = (char *)"incorrect data check"; |
|
|
|
|
strm->msg = (z_const char *)"incorrect data check"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1209,7 +1209,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { |
|
|
|
|
if (state->wrap && state->flags) { |
|
|
|
|
NEEDBITS(32); |
|
|
|
|
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { |
|
|
|
|
strm->msg = (char *)"incorrect length check"; |
|
|
|
|
strm->msg = (z_const char *)"incorrect length check"; |
|
|
|
|
state->mode = BAD; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|