summaryrefslogtreecommitdiffstats
path: root/cpukit/zlib/inflate.c
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2008-09-01 21:26:47 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2008-09-01 21:26:47 +0000
commitb4983fe4c3f633f88d7001690ff37218fb8a3245 (patch)
tree91437cedd1ed1e109c653c9188015ac465d08690 /cpukit/zlib/inflate.c
parent2008-09-01 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-b4983fe4c3f633f88d7001690ff37218fb8a3245.tar.bz2
Upgrade to zlib-1.2.3.
Diffstat (limited to 'cpukit/zlib/inflate.c')
-rw-r--r--cpukit/zlib/inflate.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/cpukit/zlib/inflate.c b/cpukit/zlib/inflate.c
index 5733437461..792fdee8e9 100644
--- a/cpukit/zlib/inflate.c
+++ b/cpukit/zlib/inflate.c
@@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2005 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -117,6 +117,7 @@ z_streamp strm;
state->head = Z_NULL;
state->wsize = 0;
state->whave = 0;
+ state->write = 0;
state->hold = 0;
state->bits = 0;
state->lencode = state->distcode = state->next = state->codes;
@@ -124,6 +125,22 @@ z_streamp strm;
return Z_OK;
}
+int ZEXPORT inflatePrime(strm, bits, value)
+z_streamp strm;
+int bits;
+int value;
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+ value &= (1L << bits) - 1;
+ state->hold += value << state->bits;
+ state->bits += bits;
+ return Z_OK;
+}
+
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
z_streamp strm;
int windowBits;
@@ -146,7 +163,7 @@ int stream_size;
ZALLOC(strm, 1, sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
- strm->state = (voidpf)state;
+ strm->state = (struct internal_state FAR *)state;
if (windowBits < 0) {
state->wrap = 0;
windowBits = -windowBits;
@@ -1310,6 +1327,7 @@ z_streamp source;
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
unsigned char FAR *window;
+ unsigned wsize;
/* check input */
if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
@@ -1334,12 +1352,17 @@ z_streamp source;
/* copy state */
zmemcpy(dest, source, sizeof(z_stream));
zmemcpy(copy, state, sizeof(struct inflate_state));
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
+ if (state->lencode >= state->codes &&
+ state->lencode <= state->codes + ENOUGH - 1) {
+ copy->lencode = copy->codes + (state->lencode - state->codes);
+ copy->distcode = copy->codes + (state->distcode - state->codes);
+ }
copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL)
- zmemcpy(window, state->window, 1U << state->wbits);
+ if (window != Z_NULL) {
+ wsize = 1U << state->wbits;
+ zmemcpy(window, state->window, wsize);
+ }
copy->window = window;
- dest->state = (voidpf)copy;
+ dest->state = (struct internal_state FAR *)copy;
return Z_OK;
}