zlib 1.2.0.4

pull/2/head v1.2.0.4
Mark Adler 13 years ago
parent 85e7d7d9ba
commit 086e982175
  1. 10
      ChangeLog
  2. 14
      FAQ
  3. 2
      Makefile
  4. 2
      Makefile.in
  5. 4
      README
  6. 2
      configure
  7. 2
      crc32.c
  8. 147
      deflate.c
  9. 10
      deflate.h
  10. 2
      gzio.c
  11. 15
      infback.c
  12. 25
      inflate.c
  13. 7
      inflate.h
  14. 12
      inftrees.c
  15. 4
      inftrees.h
  16. 2
      minigzip.c
  17. 141
      qnx/package.qpg
  18. 4
      zlib.3
  19. 20
      zlib.h
  20. 2
      zutil.c

@ -1,5 +1,15 @@
ChangeLog file for zlib ChangeLog file for zlib
Changes in 1.2.0.4 (10 August 2003)
- Minor FAQ updates
- Be more strict when checking inflateInit2's windowBits parameter
- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
- Add gzip wrapper option to deflateInit2 using windowBits
- Add updated QNX rule in configure and qnx directory [Bonnefoy]
- Make inflate distance-too-far checks more rigorous
- Clean up FAR usage in inflate
- Add casting to sizeof() in gzio.c and minigzip.c
Changes in 1.2.0.3 (19 July 2003) Changes in 1.2.0.3 (19 July 2003)
- Fix silly error in gzungetc() implementation [Vollant] - Fix silly error in gzungetc() implementation [Vollant]
- Update contrib/minizip and contrib/vstudio [Vollant] - Update contrib/minizip and contrib/vstudio [Vollant]

14
FAQ

@ -122,8 +122,16 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
18. Well that's nice, but how do I make a gzip file in memory? 18. Well that's nice, but how do I make a gzip file in memory?
Read RFC 1952 for the gzip header and trailer format, and roll your own You can request that deflate write the gzip format instead of the zlib
gzip formatted data using raw deflate and crc32(). format using deflateInit2(). You can also request that inflate decode
the gzip format using inflateInit2(). Read zlib.h for more details.
Note that you cannot specify special gzip header contents (e.g. a file
name or modification date), nor will inflate tell you what was in the
gzip header. If you need to customize the header or see what's in it,
you can use the raw deflate and inflate operations and the crc32()
function and roll your own gzip encoding and decoding. Read the gzip
RFC 1952 for details of the header and trailer format.
19. Is zlib thread-safe? 19. Is zlib thread-safe?
@ -253,7 +261,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
32. Is there a Java version of zlib? 32. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip class. If you really want as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home a version of zlib written in the Java language, look on the zlib home
page for links: http://www.zlib.org/ page for links: http://www.zlib.org/

@ -24,7 +24,7 @@ LDFLAGS=libz.a
LDSHARED=$(CC) LDSHARED=$(CC)
CPP=$(CC) -E CPP=$(CC) -E
VER=1.2.0.3 VER=1.2.0.4
LIBS=libz.a LIBS=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so

@ -24,7 +24,7 @@ LDFLAGS=libz.a
LDSHARED=$(CC) LDSHARED=$(CC)
CPP=$(CC) -E CPP=$(CC) -E
VER=1.2.0.3 VER=1.2.0.4
LIBS=libz.a LIBS=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so

@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.0.3 is a general purpose data compression library. All the code is zlib 1.2.0.4 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files (Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.0.3 are documented in the file ChangeLog. The changes made in version 1.2.0.4 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib". Unsupported third party contributions are provided in directory "contrib".

2
configure vendored

@ -78,6 +78,8 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CFLAGS="$cflags" CFLAGS="$cflags"
case `(uname -s || echo unknown) 2>/dev/null` in case `(uname -s || echo unknown) 2>/dev/null` in
Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};; Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
QNX*) #This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 (alain.bonnefoy@icbt.com)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
shared_ext='.sl' shared_ext='.sl'
SHAREDLIB='libz.sl';; SHAREDLIB='libz.sl';;

@ -18,7 +18,7 @@
# endif /* !DYNAMIC_CRC_TABLE */ # endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */ #endif /* MAKECRCH */
#include "zutil.h" #include "zutil.h" /* for STDC and FAR definitions */
#define local static #define local static

@ -52,7 +52,7 @@
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
" deflate 1.2.0.3 Copyright 1995-2003 Jean-loup Gailly "; " deflate 1.2.0.4 Copyright 1995-2003 Jean-loup Gailly ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
@ -132,12 +132,12 @@ typedef struct config_s {
local const config configuration_table[2] = { local const config configuration_table[2] = {
/* good lazy nice chain */ /* good lazy nice chain */
/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* maximum speed, no lazy matches */ /* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
#else #else
local const config configuration_table[10] = { local const config configuration_table[10] = {
/* good lazy nice chain */ /* good lazy nice chain */
/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */ /* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
/* 2 */ {4, 5, 16, 8, deflate_fast}, /* 2 */ {4, 5, 16, 8, deflate_fast},
/* 3 */ {4, 6, 32, 32, deflate_fast}, /* 3 */ {4, 6, 32, 32, deflate_fast},
@ -146,7 +146,7 @@ local const config configuration_table[10] = {
/* 6 */ {8, 16, 128, 128, deflate_slow}, /* 6 */ {8, 16, 128, 128, deflate_slow},
/* 7 */ {8, 32, 128, 256, deflate_slow}, /* 7 */ {8, 32, 128, 256, deflate_slow},
/* 8 */ {32, 128, 258, 1024, deflate_slow}, /* 8 */ {32, 128, 258, 1024, deflate_slow},
/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */ /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
#endif #endif
/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 /* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
@ -225,7 +225,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
int stream_size; int stream_size;
{ {
deflate_state *s; deflate_state *s;
int noheader = 0; int wrap = 1;
static const char my_version[] = ZLIB_VERSION; static const char my_version[] = ZLIB_VERSION;
ushf *overlay; ushf *overlay;
@ -252,10 +252,16 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
if (level == Z_DEFAULT_COMPRESSION) level = 6; if (level == Z_DEFAULT_COMPRESSION) level = 6;
#endif #endif
if (windowBits < 0) { /* undocumented feature: suppress zlib header */ if (windowBits < 0) { /* suppress zlib wrapper */
noheader = 1; wrap = 0;
windowBits = -windowBits; windowBits = -windowBits;
} }
#ifdef GZIP
else if (windowBits > 15) {
wrap = 2; /* write gzip wrapper instead */
windowBits -= 16;
}
#endif
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
strategy < 0 || strategy > Z_RLE) { strategy < 0 || strategy > Z_RLE) {
@ -267,7 +273,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
strm->state = (struct internal_state FAR *)s; strm->state = (struct internal_state FAR *)s;
s->strm = strm; s->strm = strm;
s->noheader = noheader; s->wrap = wrap;
s->w_bits = windowBits; s->w_bits = windowBits;
s->w_size = 1 << s->w_bits; s->w_size = 1 << s->w_bits;
s->w_mask = s->w_size - 1; s->w_mask = s->w_size - 1;
@ -316,11 +322,12 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
IPos hash_head = 0; IPos hash_head = 0;
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
(!strm->state->noheader && strm->state->status != INIT_STATE)) strm->state->wrap == 2 ||
(strm->state->wrap == 1 && strm->state->status != INIT_STATE))
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
s = strm->state; s = strm->state;
if (!s->noheader) if (s->wrap)
strm->adler = adler32(strm->adler, dictionary, dictLength); strm->adler = adler32(strm->adler, dictionary, dictLength);
if (length < MIN_MATCH) return Z_OK; if (length < MIN_MATCH) return Z_OK;
@ -364,11 +371,15 @@ int ZEXPORT deflateReset (strm)
s->pending = 0; s->pending = 0;
s->pending_out = s->pending_buf; s->pending_out = s->pending_buf;
if (s->noheader < 0) { if (s->wrap < 0) {
s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
} }
s->status = s->noheader ? BUSY_STATE : INIT_STATE; s->status = s->wrap ? INIT_STATE : BUSY_STATE;
strm->adler = 1; strm->adler =
#ifdef GZIP
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
#endif
adler32(0L, Z_NULL, 0);
s->last_flush = Z_NO_FLUSH; s->last_flush = Z_NO_FLUSH;
_tr_init(s); _tr_init(s);
@ -428,7 +439,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
* can emit on compressed data for some combinations of the parameters. * can emit on compressed data for some combinations of the parameters.
* *
* This function could be more sophisticated to provide closer upper bounds * This function could be more sophisticated to provide closer upper bounds
* for every combination of windowBits and memLevel, as well as noheader. * for every combination of windowBits and memLevel, as well as wrap.
* But even the conservative upper bound of about 14% expansion does not * But even the conservative upper bound of about 14% expansion does not
* seem onerous for output buffer allocation. * seem onerous for output buffer allocation.
*/ */
@ -519,33 +530,53 @@ int ZEXPORT deflate (strm, flush)
old_flush = s->last_flush; old_flush = s->last_flush;
s->last_flush = flush; s->last_flush = flush;
/* Write the zlib header */ /* Write the header */
if (s->status == INIT_STATE) { if (s->status == INIT_STATE) {
#ifdef GZIP
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; if (s->wrap == 2) {
uInt level_flags; put_byte(s, 31);
put_byte(s, 139);
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) put_byte(s, 8);
level_flags = 0; put_byte(s, 0);
else if (s->level < 6) put_byte(s, 0);
level_flags = 1; put_byte(s, 0);
else if (s->level == 6) put_byte(s, 0);
level_flags = 2; put_byte(s, 0);
put_byte(s, s->level == 9 ? 2 :
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
4 : 0));
put_byte(s, 255);
s->status = BUSY_STATE;
strm->adler = crc32(0L, Z_NULL, 0);
}
else else
level_flags = 3; #endif
header |= (level_flags << 6); {
if (s->strstart != 0) header |= PRESET_DICT; uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
header += 31 - (header % 31); uInt level_flags;
s->status = BUSY_STATE; if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
putShortMSB(s, header); level_flags = 0;
else if (s->level < 6)
/* Save the adler32 of the preset dictionary: */ level_flags = 1;
if (s->strstart != 0) { else if (s->level == 6)
putShortMSB(s, (uInt)(strm->adler >> 16)); level_flags = 2;
putShortMSB(s, (uInt)(strm->adler & 0xffff)); else
level_flags = 3;
header |= (level_flags << 6);
if (s->strstart != 0) header |= PRESET_DICT;
header += 31 - (header % 31);
s->status = BUSY_STATE;
putShortMSB(s, header);
/* Save the adler32 of the preset dictionary: */
if (s->strstart != 0) {
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
}
strm->adler = adler32(0L, Z_NULL, 0);
} }
strm->adler = 1L;
} }
/* Flush as much pending output as possible */ /* Flush as much pending output as possible */
@ -622,16 +653,31 @@ int ZEXPORT deflate (strm, flush)
Assert(strm->avail_out > 0, "bug2"); Assert(strm->avail_out > 0, "bug2");
if (flush != Z_FINISH) return Z_OK; if (flush != Z_FINISH) return Z_OK;
if (s->noheader) return Z_STREAM_END; if (s->wrap <= 0) return Z_STREAM_END;
/* Write the zlib trailer (adler32) */ /* Write the trailer */
putShortMSB(s, (uInt)(strm->adler >> 16)); #ifdef GZIP
putShortMSB(s, (uInt)(strm->adler & 0xffff)); if (s->wrap == 2) {
put_byte(s, (Byte)(strm->adler & 0xff));
put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
put_byte(s, (Byte)(strm->total_in & 0xff));
put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
}
else
#endif
{
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
}
flush_pending(strm); flush_pending(strm);
/* If avail_out is zero, the application will call deflate again /* If avail_out is zero, the application will call deflate again
* to flush the rest. * to flush the rest.
*/ */
s->noheader = -1; /* write the trailer only once! */ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
return s->pending != 0 ? Z_OK : Z_STREAM_END; return s->pending != 0 ? Z_OK : Z_STREAM_END;
} }
@ -740,9 +786,14 @@ local int read_buf(strm, buf, size)
strm->avail_in -= len; strm->avail_in -= len;
if (!strm->state->noheader) { if (strm->state->wrap == 1) {
strm->adler = adler32(strm->adler, strm->next_in, len); strm->adler = adler32(strm->adler, strm->next_in, len);
} }
#ifdef GZIP
else if (strm->state->wrap == 2) {
strm->adler = crc32(strm->adler, strm->next_in, len);
}
#endif
zmemcpy(buf, strm->next_in, len); zmemcpy(buf, strm->next_in, len);
strm->next_in += len; strm->next_in += len;
strm->total_in += len; strm->total_in += len;
@ -1044,7 +1095,7 @@ local void fill_window(s)
} else if (more == (unsigned)(-1)) { } else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if /* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done one byte at time) * strstart == 0 && lookahead == 1 (input done a byte at time)
*/ */
more--; more--;
} }
@ -1271,7 +1322,7 @@ local block_state deflate_fast(s, flush)
#ifndef FASTEST #ifndef FASTEST
if (s->match_length <= s->max_insert_length && if (s->match_length <= s->max_insert_length &&
s->lookahead >= MIN_MATCH) { s->lookahead >= MIN_MATCH) {
s->match_length--; /* string at strstart already in hash table */ s->match_length--; /* string at strstart already in table */
do { do {
s->strstart++; s->strstart++;
INSERT_STRING(s, s->strstart, hash_head); INSERT_STRING(s, s->strstart, hash_head);

@ -15,6 +15,14 @@
#include "zutil.h" #include "zutil.h"
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip encoding
should be left enabled. */
#ifndef NO_GZIP
# define GZIP
#endif
/* =========================================================================== /* ===========================================================================
* Internal compression state. * Internal compression state.
*/ */
@ -86,7 +94,7 @@ typedef struct internal_state {
ulg pending_buf_size; /* size of pending_buf */ ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */ Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */ int pending; /* nb of bytes in the pending buffer */
int noheader; /* suppress zlib header and adler32 */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
Byte data_type; /* UNKNOWN, BINARY or ASCII */ Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */ Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */ int last_flush; /* value of flush param for previous deflate call */

@ -608,7 +608,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
va_end(va); va_end(va);
# endif # endif
#endif #endif
if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
return 0; return 0;
return gzwrite(file, buf, (unsigned)len); return gzwrite(file, buf, (unsigned)len);
} }

@ -55,6 +55,7 @@ int stream_size;
state->wsize = 1U << windowBits; state->wsize = 1U << windowBits;
state->window = window; state->window = window;
state->write = 0; state->write = 0;
state->whave = 0;
return Z_OK; return Z_OK;
} }
@ -201,6 +202,7 @@ struct inflate_state FAR *state;
if (left == 0) { \ if (left == 0) { \
put = state->window; \ put = state->window; \
left = state->wsize; \ left = state->wsize; \
state->whave = left; \
if (out(out_desc, put, left)) { \ if (out(out_desc, put, left)) { \
ret = Z_BUF_ERROR; \ ret = Z_BUF_ERROR; \
goto inf_leave; \ goto inf_leave; \
@ -216,7 +218,7 @@ struct inflate_state FAR *state;
in() and out() are the call-back input and output functions. When in() and out() are the call-back input and output functions. When
inflateBack() needs more input, it calls in(). When inflateBack() has inflateBack() needs more input, it calls in(). When inflateBack() has
filled the window with output, or when it completes with data in the filled the window with output, or when it completes with data in the
window, it called out() to write out the data. The application must not window, it calls out() to write out the data. The application must not
change the provided input until in() is called again or inflateBack() change the provided input until in() is called again or inflateBack()
returns. The application must not change the window/output buffer until returns. The application must not change the window/output buffer until
inflateBack() returns. inflateBack() returns.
@ -243,12 +245,13 @@ out_func out;
void FAR *out_desc; void FAR *out_desc;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned char *next, *put; /* next input and output */ unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ unsigned long hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
unsigned char *from; /* where to copy match bytes from */ unsigned char FAR *from; /* where to copy match bytes from */
code this; /* current decoding table entry */ code this; /* current decoding table entry */
code last; /* parent table entry */ code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */ unsigned len; /* length to copy for repeats, bits to drop */
@ -265,6 +268,7 @@ void FAR *out_desc;
strm->msg = Z_NULL; strm->msg = Z_NULL;
state->mode = TYPE; state->mode = TYPE;
state->last = 0; state->last = 0;
state->whave = 0;
next = strm->next_in; next = strm->next_in;
have = next != Z_NULL ? strm->avail_in : 0; have = next != Z_NULL ? strm->avail_in : 0;
hold = 0; hold = 0;
@ -457,6 +461,8 @@ void FAR *out_desc;
/* use inflate_fast() if we have enough input and output */ /* use inflate_fast() if we have enough input and output */
if (have >= 6 && left >= 258) { if (have >= 6 && left >= 258) {
RESTORE(); RESTORE();
if (state->whave < state->wsize)
state->whave = state->wsize - left;
inflate_fast(strm, state->wsize); inflate_fast(strm, state->wsize);
LOAD(); LOAD();
break; break;
@ -547,7 +553,8 @@ void FAR *out_desc;
state->offset += BITS(state->extra); state->offset += BITS(state->extra);
DROPBITS(state->extra); DROPBITS(state->extra);
} }
if (state->offset > state->wsize) { if (state->offset > state->wsize - (state->whave < state->wsize ?
left : 0)) {
strm->msg = (char *)"invalid distance too far back"; strm->msg = (char *)"invalid distance too far back";
state->mode = BAD; state->mode = BAD;
break; break;

@ -113,6 +113,7 @@ z_streamp strm;
state->last = 0; state->last = 0;
state->havedict = 0; state->havedict = 0;
state->wsize = 0; state->wsize = 0;
state->whave = 0;
state->hold = 0; state->hold = 0;
state->bits = 0; state->bits = 0;
state->lencode = state->distcode = state->next = state->codes; state->lencode = state->distcode = state->next = state->codes;
@ -150,7 +151,7 @@ int stream_size;
else { else {
state->wrap = (windowBits >> 4) + 1; state->wrap = (windowBits >> 4) + 1;
#ifdef GUNZIP #ifdef GUNZIP
windowBits &= 15; if (windowBits < 48) windowBits &= 15;
#endif #endif
} }
if (windowBits < 8 || windowBits > 15) { if (windowBits < 8 || windowBits > 15) {
@ -320,6 +321,7 @@ unsigned out;
if (state->wsize == 0) { if (state->wsize == 0) {
state->wsize = 1U << state->wbits; state->wsize = 1U << state->wbits;
state->write = 0; state->write = 0;
state->whave = 0;
} }
/* copy state->wsize or less output bytes into the circular window */ /* copy state->wsize or less output bytes into the circular window */
@ -327,6 +329,7 @@ unsigned out;
if (copy >= state->wsize) { if (copy >= state->wsize) {
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
state->write = 0; state->write = 0;
state->whave = state->wsize;
} }
else { else {
dist = state->wsize - state->write; dist = state->wsize - state->write;
@ -336,10 +339,12 @@ unsigned out;
if (copy) { if (copy) {
zmemcpy(state->window, strm->next_out - copy, copy); zmemcpy(state->window, strm->next_out - copy, copy);
state->write = copy; state->write = copy;
state->whave = state->wsize;
} }
else { else {
state->write += dist; state->write += dist;
if (state->write == state->wsize) state->write = 0; if (state->write == state->wsize) state->write = 0;
if (state->whave < state->wsize) state->whave += dist;
} }
} }
return 0; return 0;
@ -531,13 +536,14 @@ z_streamp strm;
int flush; int flush;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned char *next, *put; /* next input and output */ unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ unsigned long hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned in, out; /* save starting available input and output */ unsigned in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
unsigned char *from; /* where to copy match bytes from */ unsigned char FAR *from; /* where to copy match bytes from */
code this; /* current decoding table entry */ code this; /* current decoding table entry */
code last; /* parent table entry */ code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */ unsigned len; /* length to copy for repeats, bits to drop */
@ -956,8 +962,7 @@ int flush;
state->offset += BITS(state->extra); state->offset += BITS(state->extra);
DROPBITS(state->extra); DROPBITS(state->extra);
} }
if (state->offset > (state->wsize ? state->wsize : if (state->offset > state->whave + out - left) {
out - left)) {
strm->msg = (char *)"invalid distance too far back"; strm->msg = (char *)"invalid distance too far back";
state->mode = BAD; state->mode = BAD;
break; break;
@ -1108,12 +1113,16 @@ uInt dictLength;
state->mode = MEM; state->mode = MEM;
return Z_MEM_ERROR; return Z_MEM_ERROR;
} }
if (dictLength > state->wsize) if (dictLength > state->wsize) {
zmemcpy(state->window, dictionary + dictLength - state->wsize, zmemcpy(state->window, dictionary + dictLength - state->wsize,
state->wsize); state->wsize);
else state->whave = state->wsize;
}
else {
zmemcpy(state->window + state->wsize - dictLength, dictionary, zmemcpy(state->window + state->wsize - dictLength, dictionary,
dictLength); dictLength);
state->whave = dictLength;
}
state->havedict = 1; state->havedict = 1;
Tracev((stderr, "inflate: dictionary set\n")); Tracev((stderr, "inflate: dictionary set\n"));
return Z_OK; return Z_OK;
@ -1131,7 +1140,7 @@ uInt dictLength;
zero for the first call. zero for the first call.
*/ */
local unsigned syncsearch(have, buf, len) local unsigned syncsearch(have, buf, len)
unsigned *have; unsigned FAR *have;
unsigned char FAR *buf; unsigned char FAR *buf;
unsigned len; unsigned len;
{ {

@ -8,11 +8,11 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* define NO_GUNZIP when compiling if you want to disable gzip header and /* define NO_GZIP when compiling if you want to disable gzip header and
trailer decoding by inflate(). NO_GUNZIP would be used to avoid linking in trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip decoding the crc code when it is not needed. For shared libraries, gzip decoding
should be left enabled. */ should be left enabled. */
#ifndef NO_GUNZIP #ifndef NO_GZIP
# define GUNZIP # define GUNZIP
#endif #endif
@ -88,6 +88,7 @@ struct inflate_state {
/* sliding window */ /* sliding window */
unsigned wbits; /* log base 2 of requested window size */ unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */ unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */ unsigned write; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */ unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */ /* bit accumulator */

@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.2.0.3 Copyright 1995-2003 Mark Adler "; " inflate 1.2.0.4 Copyright 1995-2003 Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
@ -33,8 +33,8 @@ int inflate_table(type, lens, codes, table, bits, work)
codetype type; codetype type;
unsigned short FAR *lens; unsigned short FAR *lens;
unsigned codes; unsigned codes;
code * FAR *table; code FAR * FAR *table;
unsigned *bits; unsigned FAR *bits;
unsigned short FAR *work; unsigned short FAR *work;
{ {
unsigned len; /* a code's length in bits */ unsigned len; /* a code's length in bits */
@ -52,8 +52,8 @@ unsigned short FAR *work;
unsigned mask; /* mask for low root bits */ unsigned mask; /* mask for low root bits */
code this; /* table entry for duplication */ code this; /* table entry for duplication */
code FAR *next; /* next available space in table */ code FAR *next; /* next available space in table */
const unsigned short *base; /* base value table to use */ const unsigned short FAR *base; /* base value table to use */
const unsigned short *extra; /* extra bits table to use */ const unsigned short FAR *extra; /* extra bits table to use */
int end; /* use base and extra for symbol > end */ int end; /* use base and extra for symbol > end */
unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short count[MAXBITS+1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 193, 193}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 192};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

@ -51,5 +51,5 @@ typedef enum {
} codetype; } codetype;
extern int inflate_table OF((codetype type, unsigned short FAR *lens, extern int inflate_table OF((codetype type, unsigned short FAR *lens,
unsigned codes, code * FAR *table, unsigned *bits, unsigned codes, code FAR * FAR *table,
unsigned short FAR *work)); unsigned FAR *bits, unsigned short FAR *work));

@ -60,7 +60,7 @@
#ifndef GZ_SUFFIX #ifndef GZ_SUFFIX
# define GZ_SUFFIX ".gz" # define GZ_SUFFIX ".gz"
#endif #endif
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) #define SUFFIX_LEN ((int)sizeof(GZ_SUFFIX)-1)
#define BUFLEN 16384 #define BUFLEN 16384
#define MAX_NAME_LEN 1024 #define MAX_NAME_LEN 1024

@ -0,0 +1,141 @@
<QPG:Generation>
<QPG:Options>
<QPG:User unattended="no" verbosity="2" listfiles="yes"/>
<QPG:Defaults type="qnx_package"/>
<QPG:Source></QPG:Source>
<QPG:Release number="+"/>
<QPG:Build></QPG:Build>
<QPG:FileSorting strip="yes"/>
<QPG:Package targets="combine"/>
<QPG:Repository generate="yes"/>
<QPG:FinalDir></QPG:FinalDir>
<QPG:Cleanup></QPG:Cleanup>
</QPG:Options>
<QPG:Responsible>
<QPG:Company></QPG:Company>
<QPG:Department></QPG:Department>
<QPG:Group></QPG:Group>
<QPG:Team></QPG:Team>
<QPG:Employee></QPG:Employee>
<QPG:EmailAddress></QPG:EmailAddress>
</QPG:Responsible>
<QPG:Values>
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.2.0.4" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.0.4"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.0.4"/>
<QPG:Add file="../libz.so.1.2.0.4" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
<QPM:PackageManifest>
<QPM:PackageDescription>
<QPM:PackageType>Library</QPM:PackageType>
<QPM:PackageReleaseNotes></QPM:PackageReleaseNotes>
<QPM:PackageReleaseUrgency>Medium</QPM:PackageReleaseUrgency>
<QPM:PackageRepository></QPM:PackageRepository>
<QPM:FileVersion>2.0</QPM:FileVersion>
</QPM:PackageDescription>
<QPM:ProductDescription>
<QPM:ProductName>zlib</QPM:ProductName>
<QPM:ProductIdentifier>zlib</QPM:ProductIdentifier>
<QPM:ProductEmail>alain.bonnefoy@icbt.com</QPM:ProductEmail>
<QPM:VendorName>Public</QPM:VendorName>
<QPM:VendorInstallName>public</QPM:VendorInstallName>
<QPM:VendorURL>www.gzip.org/zlib</QPM:VendorURL>
<QPM:VendorEmbedURL></QPM:VendorEmbedURL>
<QPM:VendorEmail></QPM:VendorEmail>
<QPM:AuthorName>Jean-Loup Gailly,Mark Adler</QPM:AuthorName>
<QPM:AuthorURL>www.gzip.org/zlib</QPM:AuthorURL>
<QPM:AuthorEmbedURL></QPM:AuthorEmbedURL>
<QPM:AuthorEmail>zlib@gzip.org</QPM:AuthorEmail>
<QPM:ProductIconSmall></QPM:ProductIconSmall>
<QPM:ProductIconLarge></QPM:ProductIconLarge>
<QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
<QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
<QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL>
</QPM:ProductDescription>
<QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.2.0.4</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
<QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor>
<QPM:ExcludeCountries>
<QPM:Country></QPM:Country>
</QPM:ExcludeCountries>
<QPM:ReleaseCopyright>No License</QPM:ReleaseCopyright>
</QPM:ReleaseDescription>
<QPM:ContentDescription>
<QPM:ContentTopic xmlmultiple="true">Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
<QPM:ContentKeyword>zlib,compression</QPM:ContentKeyword>
<QPM:TargetOS>qnx6</QPM:TargetOS>
<QPM:HostOS>qnx6</QPM:HostOS>
<QPM:DisplayEnvironment xmlmultiple="true">None</QPM:DisplayEnvironment>
<QPM:TargetAudience xmlmultiple="true">Developer</QPM:TargetAudience>
</QPM:ContentDescription>
</QPM:PackageManifest>
</QPG:PackageFilter>
<QPG:PackageFilter proc="none" target="none">
<QPM:PackageManifest>
<QPM:ProductInstallationDependencies>
<QPM:ProductRequirements></QPM:ProductRequirements>
</QPM:ProductInstallationDependencies>
<QPM:ProductInstallationProcedure>
<QPM:Script xmlmultiple="true">
<QPM:ScriptName></QPM:ScriptName>
<QPM:ScriptType>Install</QPM:ScriptType>
<QPM:ScriptTiming>Post</QPM:ScriptTiming>
<QPM:ScriptBlocking>No</QPM:ScriptBlocking>
<QPM:ScriptResult>Ignore</QPM:ScriptResult>
<QPM:ShortDescription></QPM:ShortDescription>
<QPM:UseBinaries>No</QPM:UseBinaries>
<QPM:Priority>Optional</QPM:Priority>
</QPM:Script>
</QPM:ProductInstallationProcedure>
</QPM:PackageManifest>
<QPM:Launch>
</QPM:Launch>
</QPG:PackageFilter>
<QPG:PackageFilter type="core" component="none">
<QPM:PackageManifest>
<QPM:ProductInstallationProcedure>
<QPM:OrderDependency xmlmultiple="true">
<QPM:Order>InstallOver</QPM:Order>
<QPM:Product>zlib</QPM:Product>
</QPM:OrderDependency>
</QPM:ProductInstallationProcedure>
</QPM:PackageManifest>
<QPM:Launch>
</QPM:Launch>
</QPG:PackageFilter>
<QPG:PackageFilter type="core" component="dev">
<QPM:PackageManifest>
<QPM:ProductInstallationProcedure>
<QPM:OrderDependency xmlmultiple="true">
<QPM:Order>InstallOver</QPM:Order>
<QPM:Product>zlib-dev</QPM:Product>
</QPM:OrderDependency>
</QPM:ProductInstallationProcedure>
</QPM:PackageManifest>
<QPM:Launch>
</QPM:Launch>
</QPG:PackageFilter>
</QPG:Values>
</QPG:Generation>

@ -1,4 +1,4 @@
.TH ZLIB 3 "12 May 2003" .TH ZLIB 3 "xx July 2003"
.SH NAME .SH NAME
zlib \- compression/decompression library zlib \- compression/decompression library
.SH SYNOPSIS .SH SYNOPSIS
@ -133,7 +133,7 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org, Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS .SH AUTHORS
Version 1.2.0.3 Version 1.2.0.4
Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org) Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu). and Mark Adler (madler@alumni.caltech.edu).
.LP .LP

@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library /* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.0.3, July 19th, 2003 version 1.2.0.4, August 10th, 2003
Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler
@ -37,8 +37,8 @@
extern "C" { extern "C" {
#endif #endif
#define ZLIB_VERSION "1.2.0.3" #define ZLIB_VERSION "1.2.0.4"
#define ZLIB_VERNUM 0x1203 #define ZLIB_VERNUM 0x1204
/* /*
The 'zlib' compression library provides in-memory compression and The 'zlib' compression library provides in-memory compression and
@ -446,15 +446,21 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
this version of the library. this version of the library.
The windowBits parameter is the base two logarithm of the window size The windowBits parameter is the base two logarithm of the window size
(the size of the history buffer). It should be in the range 8..15 for this (the size of the history buffer). It should be in the range 8..15 for this
version of the library. Larger values of this parameter result in better version of the library. Larger values of this parameter result in better
compression at the expense of memory usage. The default value is 15 if compression at the expense of memory usage. The default value is 15 if
deflateInit is used instead. deflateInit is used instead.
windowBits can also be -8..-15 for raw deflate. In this case, -windowBits windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
determines the window size. deflate() will then generate raw deflate data determines the window size. deflate() will then generate raw deflate data
with no zlib header or trailer, and will not compute an adler32 check value. with no zlib header or trailer, and will not compute an adler32 check value.
windowBits can also be greater than 15 for optional gzip encoding. Add
16 to windowBits to write a simple gzip header and trailer around the
compressed data instead of a zlib wrapper. The gzip header will have no
file name, no extra data, no comment, no modification time (set to zero),
no header crc, and the operating system will be set to 255 (unknown).
The memLevel parameter specifies how much memory should be allocated The memLevel parameter specifies how much memory should be allocated
for the internal compression state. memLevel=1 uses minimum memory but for the internal compression state. memLevel=1 uses minimum memory but
is slow and reduces compression ratio; memLevel=9 uses maximum memory is slow and reduces compression ratio; memLevel=9 uses maximum memory
@ -801,8 +807,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
Library content (indicates missing functionality): Library content (indicates missing functionality):
16: NO_DEFLATE -- gz* functions cannot compress (to avoid linking deflate 16: NO_DEFLATE -- gz* functions cannot compress (to avoid linking deflate
code when not needed) code when not needed)
17: NO_GUNZIP -- inflate can't detect and decode gzip streams, to avoid 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
linking crc code and decode gzip streams (to avoid linking crc code)
18-19: 0 (reserved) 18-19: 0 (reserved)
Operation variations (changes in library functionality): Operation variations (changes in library functionality):

@ -74,7 +74,7 @@ uLong ZEXPORT zlibCompileFlags()
#ifdef NO_DEFLATE #ifdef NO_DEFLATE
flags += 1 << 16; flags += 1 << 16;
#endif #endif
#ifdef NO_GUNZIP #ifdef NO_GZIP
flags += 1 << 17; flags += 1 << 17;
#endif #endif
#ifdef PKZIP_BUG_WORKAROUND #ifdef PKZIP_BUG_WORKAROUND

Loading…
Cancel
Save