summaryrefslogtreecommitdiff
path: root/lib/zlib/inflate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zlib/inflate.c')
-rw-r--r--lib/zlib/inflate.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/zlib/inflate.c b/lib/zlib/inflate.c
index f7e81fc8b2a..8f767b7b9d2 100644
--- a/lib/zlib/inflate.c
+++ b/lib/zlib/inflate.c
@@ -21,7 +21,7 @@ int ZEXPORT inflateReset(z_streamp strm)
state->head = Z_NULL;
state->wsize = 0;
state->whave = 0;
- state->wnext = 0;
+ state->write = 0;
state->hold = 0;
state->bits = 0;
state->lencode = state->distcode = state->next = state->codes;
@@ -30,11 +30,14 @@ int ZEXPORT inflateReset(z_streamp strm)
return Z_OK;
}
-int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
+int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version,
int stream_size)
{
struct inflate_state FAR *state;
+ if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
+ stream_size != (int)(sizeof(z_stream)))
+ return Z_VERSION_ERROR;
if (strm == Z_NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */
if (strm->zalloc == (alloc_func)0) {
@@ -67,9 +70,9 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
return inflateReset(strm);
}
-int ZEXPORT inflateInit_(z_streamp strm, int stream_size)
+int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
{
- return inflateInit2_(strm, DEF_WBITS, stream_size);
+ return inflateInit2_(strm, DEF_WBITS, version, stream_size);
}
local void fixedtables(struct inflate_state FAR *state)
@@ -112,7 +115,7 @@ local int updatewindow(z_streamp strm, unsigned out)
/* if window not in use yet, initialize */
if (state->wsize == 0) {
state->wsize = 1U << state->wbits;
- state->wnext = 0;
+ state->write = 0;
state->whave = 0;
}
@@ -120,22 +123,22 @@ local int updatewindow(z_streamp strm, unsigned out)
copy = out - strm->avail_out;
if (copy >= state->wsize) {
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->wnext = 0;
+ state->write = 0;
state->whave = state->wsize;
}
else {
- dist = state->wsize - state->wnext;
+ dist = state->wsize - state->write;
if (dist > copy) dist = copy;
- zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
+ zmemcpy(state->window + state->write, strm->next_out - copy, dist);
copy -= dist;
if (copy) {
zmemcpy(state->window, strm->next_out - copy, copy);
- state->wnext = copy;
+ state->write = copy;
state->whave = state->wsize;
}
else {
- state->wnext += dist;
- if (state->wnext == state->wsize) state->wnext = 0;
+ state->write += dist;
+ if (state->write == state->wsize) state->write = 0;
if (state->whave < state->wsize) state->whave += dist;
}
}
@@ -820,12 +823,12 @@ int ZEXPORT inflate(z_streamp strm, int flush)
copy = out - left;
if (state->offset > copy) { /* copy from window */
copy = state->offset - copy;
- if (copy > state->wnext) {
- copy -= state->wnext;
+ if (copy > state->write) {
+ copy -= state->write;
from = state->window + (state->wsize - copy);
}
else
- from = state->window + (state->wnext - copy);
+ from = state->window + (state->write - copy);
if (copy > state->length) copy = state->length;
}
else { /* copy from output */