summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:26:29 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:26:29 -0700
commit639be997883d9016baaf46017a2802b2ce1698bd (patch)
treedb90fc577d10564b335980824111e8d11c5527e2
parentd6231142d2b883a8c3b253fa34992b5cdb4ac2fe (diff)
downloadzlib-639be997883d9016baaf46017a2802b2ce1698bd.tar.gz
zlib 1.2.3.3v1.2.3.3
-rw-r--r--ChangeLog14
-rw-r--r--Makefile41
-rw-r--r--Makefile.in41
-rw-r--r--README4
-rw-r--r--adler32.c44
-rw-r--r--as400/zlib.inc6
-rwxr-xr-xconfigure49
-rw-r--r--contrib/infback9/infback9.c80
-rw-r--r--contrib/infback9/inftree9.c4
-rw-r--r--contrib/vstudio/vc7/zlib.rc6
-rw-r--r--crc32.c41
-rw-r--r--deflate.c2
-rw-r--r--gzio.c121
-rw-r--r--infback.c80
-rw-r--r--inffast.c57
-rw-r--r--inflate.c123
-rw-r--r--inflate.h1
-rw-r--r--inftrees.c42
-rw-r--r--qnx/package.qpg10
-rw-r--r--zlib.36
-rw-r--r--zlib.h45
-rw-r--r--zutil.h6
22 files changed, 583 insertions, 240 deletions
diff --git a/ChangeLog b/ChangeLog
index 3fa7ae1..1bc7105 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,20 @@
ChangeLog file for zlib
+Changes in 1.2.3.3 (2 October 2006)
+- Make --shared the default for configure, add a --static option
+- Add compile option to permit invalid distance-too-far streams
+- Add inflateUndermine() function which is required to enable above
+- Remove use of "this" variable name for C++ compatibility [Marquess]
+- Add testing of shared library in make test, if shared library built
+- Use ftello() and fseeko() if available instead of ftell() and fseek()
+- Provide two versions of all functions that use the z_off_t type for
+ binary compatibility -- a normal version and a 64-bit offset version,
+ per the Large File Support Extension when _LARGEFILE64_SUPPORT is
+ defined; use the 64-bit versions by default when _FILE_OFFSET_BITS
+ is defined to be 64
+- Add a --uname= option to configure to perhaps help with cross-compiling
+
Changes in 1.2.3.2 (3 September 2006)
- Turn off silly Borland warnings [Hay]
- Use off64_t and define _LARGEFILE64_SOURCE when present
diff --git a/Makefile b/Makefile
index 8c77268..2fa2e25 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3.2
+SHAREDLIBV=libz.so.1.2.3.3
SHAREDLIBM=libz.so.1
AR=ar
@@ -61,12 +61,14 @@ PIC_OBJS = $(OBJS:%.o=%.lo)
TEST_OBJS = example.o minigzip.o
-all: example$(EXE) minigzip$(EXE)
+allstatic: example$(EXE) minigzip$(EXE)
-check: test
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
+allshared: examplesh$(EXE) minigzipsh$(EXE)
+
+all: allstatic allshared
+
+teststatic: allstatic
+ @echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
@@ -74,6 +76,22 @@ test: all
echo ' *** zlib test FAILED ***'; \
fi
+testshared: allshared
+ @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
+ DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
+ SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
+ echo hello world | ./minigzipsh | ./minigzipsh -d || \
+ echo ' *** minigzip shared test FAILED ***' ; \
+ if ./examplesh; then \
+ echo ' *** zlib shared test OK ***'; \
+ else \
+ echo ' *** zlib shared test FAILED ***'; \
+ fi
+
+test: teststatic testshared
+
+check: test
+
libz.a: $(OBJS)
$(AR) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
@@ -105,6 +123,12 @@ example$(EXE): example.o $(LIBS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
+examplesh$(EXE): example.o $(LIBS)
+ $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIB)
+
+minigzipsh$(EXE): minigzip.o $(LIBS)
+ $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIB)
+
install-libs: $(LIBS)
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
@@ -142,7 +166,8 @@ uninstall:
mostlyclean: clean
clean:
- rm -f *.o *.lo *~ example$(EXE) minigzip$(EXE) \
+ rm -f *.o *.lo *~ \
+ example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
@@ -180,13 +205,11 @@ adler32.lo: zlib.h zconf.h zlibdefs.h
compress.lo: zlib.h zconf.h zlibdefs.h
crc32.lo: crc32.h zlib.h zconf.h zlibdefs.h
deflate.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-example.lo: zlib.h zconf.h zlibdefs.h
gzio.lo: zutil.h zlib.h zconf.h zlibdefs.h
inffast.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
inflate.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
infback.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
inftrees.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-minigzip.lo: zlib.h zconf.h zlibdefs.h
trees.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
uncompr.lo: zlib.h zconf.h zlibdefs.h
zutil.lo: zutil.h zlib.h zconf.h zlibdefs.h
diff --git a/Makefile.in b/Makefile.in
index 8c77268..2fa2e25 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -32,7 +32,7 @@ CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3.2
+SHAREDLIBV=libz.so.1.2.3.3
SHAREDLIBM=libz.so.1
AR=ar
@@ -61,12 +61,14 @@ PIC_OBJS = $(OBJS:%.o=%.lo)
TEST_OBJS = example.o minigzip.o
-all: example$(EXE) minigzip$(EXE)
+allstatic: example$(EXE) minigzip$(EXE)
-check: test
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
+allshared: examplesh$(EXE) minigzipsh$(EXE)
+
+all: allstatic allshared
+
+teststatic: allstatic
+ @echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
@@ -74,6 +76,22 @@ test: all
echo ' *** zlib test FAILED ***'; \
fi
+testshared: allshared
+ @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
+ DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
+ SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
+ echo hello world | ./minigzipsh | ./minigzipsh -d || \
+ echo ' *** minigzip shared test FAILED ***' ; \
+ if ./examplesh; then \
+ echo ' *** zlib shared test OK ***'; \
+ else \
+ echo ' *** zlib shared test FAILED ***'; \
+ fi
+
+test: teststatic testshared
+
+check: test
+
libz.a: $(OBJS)
$(AR) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
@@ -105,6 +123,12 @@ example$(EXE): example.o $(LIBS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
+examplesh$(EXE): example.o $(LIBS)
+ $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIB)
+
+minigzipsh$(EXE): minigzip.o $(LIBS)
+ $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIB)
+
install-libs: $(LIBS)
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
@@ -142,7 +166,8 @@ uninstall:
mostlyclean: clean
clean:
- rm -f *.o *.lo *~ example$(EXE) minigzip$(EXE) \
+ rm -f *.o *.lo *~ \
+ example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
@@ -180,13 +205,11 @@ adler32.lo: zlib.h zconf.h zlibdefs.h
compress.lo: zlib.h zconf.h zlibdefs.h
crc32.lo: crc32.h zlib.h zconf.h zlibdefs.h
deflate.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-example.lo: zlib.h zconf.h zlibdefs.h
gzio.lo: zutil.h zlib.h zconf.h zlibdefs.h
inffast.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
inflate.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
infback.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
inftrees.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-minigzip.lo: zlib.h zconf.h zlibdefs.h
trees.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
uncompr.lo: zlib.h zconf.h zlibdefs.h
zutil.lo: zutil.h zlib.h zconf.h zlibdefs.h
diff --git a/README b/README
index e22d1fa..75cae36 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.3.2 is a general purpose data compression library. All the code is
+zlib 1.2.3.3 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
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -33,7 +33,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
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-The changes made in version 1.2.3.2 are documented in the file ChangeLog.
+The changes made in version 1.2.3.3 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
diff --git a/adler32.c b/adler32.c
index 007ba26..8bf7dc4 100644
--- a/adler32.c
+++ b/adler32.c
@@ -1,5 +1,5 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,6 +8,15 @@
#define ZLIB_INTERNAL
#include "zlib.h"
+#define local static
+
+#ifdef _LARGEFILE64_SOURCE
+ local uLong adler32_combine_(uLong adler1, uLong adler2, off64_t len2);
+#else
+ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off_t len2);
+#endif
+
+
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -125,10 +134,14 @@ uLong ZEXPORT adler32(adler, buf, len)
}
/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
+#ifdef _LARGEFILE64_SOURCE
+ off64_t len2;
+#else
z_off_t len2;
+#endif
{
unsigned long sum1;
unsigned long sum2;
@@ -147,3 +160,30 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
if (sum2 > BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
+
+/* ========================================================================= */
+uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ z_off_t len2;
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+
+#ifdef _LARGEFILE64_SOURCE
+uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ off64_t len2;
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+#else
+uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ z_off_t len2;
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+#endif
diff --git a/as400/zlib.inc b/as400/zlib.inc
index fcf1791..4436477 100644
--- a/as400/zlib.inc
+++ b/as400/zlib.inc
@@ -1,7 +1,7 @@
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
- * Version 1.2.3.2
+ * Version 1.2.3.3
*
*
* WARNING:
@@ -22,8 +22,8 @@
*
* Versioning information.
*
- D ZLIB_VERSION C '1.2.3.2'
- D ZLIB_VERNUM C X'1232'
+ D ZLIB_VERSION C '1.2.3.3'
+ D ZLIB_VERNUM C X'1233'
*
* Other equates.
*
diff --git a/configure b/configure
index 6e8060e..cc97872 100755
--- a/configure
+++ b/configure
@@ -32,7 +32,7 @@ libdir=${libdir-'${exec_prefix}/lib'}
includedir=${includedir-'${prefix}/include'}
mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so'
-shared=0
+shared=1
zprefix=0
gcc=0
old_cc="$CC"
@@ -50,11 +50,13 @@ case "$1" in
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
+ -u*=* | --uname=*) uname=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
-p* | --prefix) prefix="$2"; shift; shift;;
-e* | --eprefix) exec_prefix="$2"; shift; shift;;
-l* | --libdir) libdir="$2"; shift; shift;;
-i* | --includedir) includedir="$2"; shift; shift;;
-s* | --shared | --enable-shared) shared=1; shift;;
+ -t | --static) shared=0; shift;;
-z* | --zprefix) zprefix=1; shift;;
--sysconfdir=*) echo "ignored option: --sysconfdir"; shift;;
--localstatedir=*) echo "ignored option: --localstatedir"; shift;;
@@ -80,7 +82,10 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
SFLAGS="${CFLAGS-"-O3"} -fPIC"
CFLAGS="${CFLAGS-"-O3"}"
- case `(uname -s || echo unknown) 2>/dev/null` in
+ if test -z $uname; then
+ uname=`(uname -s || echo unknown) 2>/dev/null`
+ fi
+ case "$uname" in
Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"};;
CYGWIN* | Cygwin* | cygwin* | OS/2* )
EXE='.exe';;
@@ -107,7 +112,10 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
else
# find system name and corresponding cc options
CC=${CC-cc}
- case `(uname -sr || echo unknown) 2>/dev/null` in
+ if test -z $uname; then
+ uname=`(uname -sr || echo unknown) 2>/dev/null`
+ fi
+ case "$uname" in
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
CFLAGS=${CFLAGS-"-O"}
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
@@ -200,7 +208,12 @@ if test $shared -eq 1; then
fi
if test $shared -eq 0; then
LDSHARED="$CC"
+ ALL="allstatic"
+ TEST="teststatic"
echo Building static library $LIBS version $VER with $CC.
+else
+ ALL="allstatic allshared"
+ TEST="teststatic testshared"
fi
cat > zlibdefs.h << EOF
@@ -215,15 +228,27 @@ cat > $test.c <<EOF
#include <sys/types.h>
off64_t dummy = 0;
EOF
-if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE $test.c) 2>&1`" = ""; then
- cat >> zlibdefs.h <<EOF
-#define z_off_t off64_t
-EOF
- CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE"
- SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE"
+if test "`($CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c) 2>&1`" = ""; then
+ CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
+ SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
echo "Checking for off64_t... Yes."
+ echo "Checking for fseeko... Yes."
else
echo "Checking for off64_t... No."
+ cat > $test.c <<EOF
+#include <stdio.h>
+int main(void) {
+ fseeko(NULL, 0, 0);
+ return 0;
+}
+EOF
+ if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
+ echo "Checking for fseeko... Yes."
+ else
+ CFLAGS="${CFLAGS} -DNO_FSEEKO"
+ SFLAGS="${SFLAGS} -DNO_FSEEKO"
+ echo "Checking for fseeko... No."
+ fi
fi
cat > $test.c <<EOF
@@ -491,8 +516,9 @@ sed < Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
-/^CPP *=/s#=.*#=$CPP#
+/^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^LDSHARED *=/s#=.*#=$LDSHARED#
+/^CPP *=/s#=.*#=$CPP#
/^LIBS *=/s#=.*#=$LIBS#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
@@ -505,7 +531,8 @@ sed < Makefile.in "
/^libdir *=/s#=.*#=$libdir#
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
-/^LDFLAGS *=/s#=.*#=$LDFLAGS#
+/^all: */s#:.*#: $ALL#
+/^test: */s#:.*#: $TEST#
" > Makefile
sed < zlib.pc.in "
diff --git a/contrib/infback9/infback9.c b/contrib/infback9/infback9.c
index f5ddde6..c5547ae 100644
--- a/contrib/infback9/infback9.c
+++ b/contrib/infback9/infback9.c
@@ -1,5 +1,5 @@
/* infback9.c -- inflate deflate64 data using a call-back interface
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -242,7 +242,7 @@ void FAR *out_desc;
code const FAR *distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -384,19 +384,19 @@ void FAR *out_desc;
state->have = 0;
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = lencode[BITS(lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
mode = BAD;
@@ -406,16 +406,16 @@ void FAR *out_desc;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -460,28 +460,28 @@ void FAR *out_desc;
case LEN:
/* get a literal, length, or end-of-block code */
for (;;) {
- this = lencode[BITS(lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = lencode[BITS(lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = lencode[last.val +
+ here = lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- length = (unsigned)this.val;
+ DROPBITS(here.bits);
+ length = (unsigned)here.val;
/* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ if (here.op == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
ROOM();
*put++ = (unsigned char)(length);
left--;
@@ -490,21 +490,21 @@ void FAR *out_desc;
}
/* process end of block */
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
mode = TYPE;
break;
}
/* invalid code */
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
mode = BAD;
break;
}
/* length code -- get extra bits, if any */
- extra = (unsigned)(this.op) & 31;
+ extra = (unsigned)(here.op) & 31;
if (extra != 0) {
NEEDBITS(extra);
length += BITS(extra);
@@ -514,30 +514,30 @@ void FAR *out_desc;
/* get distance code */
for (;;) {
- this = distcode[BITS(distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = distcode[BITS(distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = distcode[last.val +
+ here = distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
mode = BAD;
break;
}
- offset = (unsigned)this.val;
+ offset = (unsigned)here.val;
/* get distance extra bits, if any */
- extra = (unsigned)(this.op) & 15;
+ extra = (unsigned)(here.op) & 15;
if (extra != 0) {
NEEDBITS(extra);
offset += BITS(extra);
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c
index dede93b..c24302b 100644
--- a/contrib/infback9/inftree9.c
+++ b/contrib/infback9/inftree9.c
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate9_copyright[] =
- " inflate9 1.2.3.2 Copyright 1995-2006 Mark Adler ";
+ " inflate9 1.2.3.3 Copyright 1995-2006 Mark Adler ";
/*
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
@@ -64,7 +64,7 @@ unsigned short FAR *work;
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
- 133, 133, 133, 133, 144, 192, 204};
+ 133, 133, 133, 133, 144, 201, 203};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/contrib/vstudio/vc7/zlib.rc b/contrib/vstudio/vc7/zlib.rc
index 71d827b..39eca7e 100644
--- a/contrib/vstudio/vc7/zlib.rc
+++ b/contrib/vstudio/vc7/zlib.rc
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
- FILEVERSION 1,2,3,2
- PRODUCTVERSION 1,2,3,2
+ FILEVERSION 1,2,3,3
+ PRODUCTVERSION 1,2,3,3
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression library\0"
- VALUE "FileVersion", "1.2.3.2\0"
+ VALUE "FileVersion", "1.2.3.3\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlib.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
diff --git a/crc32.c b/crc32.c
index f658a9e..b34a510 100644
--- a/crc32.c
+++ b/crc32.c
@@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -68,6 +68,12 @@
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
+#ifdef _LARGEFILE64_SOURCE
+ local uLong crc32_combine_(uLong crc1, uLong crc2, off64_t len2);
+#else
+ local uLong crc32_combine_(uLong crc1, uLong crc2, z_off_t len2);
+#endif
+
#ifdef DYNAMIC_CRC_TABLE
@@ -367,10 +373,14 @@ local void gf2_matrix_square(square, mat)
}
/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
+local uLong crc32_combine_(crc1, crc2, len2)
uLong crc1;
uLong crc2;
+#ifdef _LARGEFILE64_SOURCE
+ off64_t len2;
+#else
z_off_t len2;
+#endif
{
int n;
unsigned long row;
@@ -421,3 +431,30 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
crc1 ^= crc2;
return crc1;
}
+
+/* ========================================================================= */
+uLong ZEXPORT crc32_combine(crc1, crc2, len2)
+ uLong crc1;
+ uLong crc2;
+ z_off_t len2;
+{
+ return crc32_combine_(crc1, crc2, len2);
+}
+
+#ifdef _LARGEFILE64_SOURCE
+uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
+ uLong crc1;
+ uLong crc2;
+ off64_t len2;
+{
+ return crc32_combine_(crc1, crc2, len2);
+}
+#else
+uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
+ uLong crc1;
+ uLong crc2;
+ z_off_t len2;
+{
+ return crc32_combine_(crc1, crc2, len2);
+}
+#endif
diff --git a/deflate.c b/deflate.c
index 181159e..fc41b80 100644
--- a/deflate.c
+++ b/deflate.c
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.3.2 Copyright 1995-2006 Jean-loup Gailly ";
+ " deflate 1.2.3.3 Copyright 1995-2006 Jean-loup Gailly ";
/*
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
diff --git a/gzio.c b/gzio.c
index a8130ef..df34620 100644
--- a/gzio.c
+++ b/gzio.c
@@ -7,6 +7,15 @@
/* @(#) $Id$ */
+#ifdef _LARGEFILE64_SOURCE
+# ifndef _LARGEFILE_SOURCE
+# define _LARGEFILE_SOURCE
+# endif
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+#endif
+
#include "zutil.h"
#include <stdio.h>
@@ -39,6 +48,14 @@ extern voidp malloc OF((uInt size));
extern void free OF((voidpf ptr));
#endif
+#ifdef NO_FSEEKO
+# define FSEEK fseek
+# define FTELL ftell
+#else
+# define FSEEK fseeko
+# define FTELL ftello
+#endif
+
#define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);}
@@ -64,15 +81,27 @@ typedef struct gz_stream {
char *path; /* path name for debugging only */
int transparent; /* 1 if input file is not a .gz file */
char mode; /* 'w' or 'r' */
+#ifdef _LARGEFILE64_SOURCE
+ off64_t start; /* start of compressed data in file (header skipped) */
+ off64_t in; /* bytes into deflate or inflate */
+ off64_t out; /* bytes out of deflate or inflate */
+#else
z_off_t start; /* start of compressed data in file (header skipped) */
z_off_t in; /* bytes into deflate or inflate */
z_off_t out; /* bytes out of deflate or inflate */
+#endif
int back; /* one character push-back */
int last; /* true if push-back is last character */
} gz_stream;
-local gzFile gz_open OF((const char *path, const char *mode, int fd));
+local gzFile gz_open OF((const char *path, const char *mode, int fd,
+ int use64));
+#ifdef _LARGEFILE64_SOURCE
+local off64_t gz_seek OF((gzFile file, off64_t offset, int whence, int use64));
+#else
+local z_off_t gz_seek OF((gzFile file, z_off_t offset, int whence, int use64));
+#endif
local int do_flush OF((gzFile file, int flush));
local int get_byte OF((gz_stream *s));
local void check_header OF((gz_stream *s));
@@ -89,10 +118,11 @@ local uLong getLong OF((gz_stream *s));
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR).
*/
-local gzFile gz_open (path, mode, fd)
+local gzFile gz_open (path, mode, fd, use64)
const char *path;
const char *mode;
int fd;
+ int use64;
{
int err;
int level = Z_DEFAULT_COMPRESSION; /* compression level */
@@ -164,12 +194,7 @@ local gzFile gz_open (path, mode, fd)
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
+ /* windowBits is passed < 0 to tell that there is no zlib header */
if (err != Z_OK || s->inbuf == Z_NULL) {
return destroy(s), (gzFile)Z_NULL;
}
@@ -177,7 +202,8 @@ local gzFile gz_open (path, mode, fd)
s->stream.avail_out = Z_BUFSIZE;
errno = 0;
- s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
+ s->file = fd < 0 ? (use64 ? F_OPEN64(path, fmode) : F_OPEN(path, fmode)) :
+ (FILE*)fdopen(fd, fmode);
if (s->file == NULL) {
return destroy(s), (gzFile)Z_NULL;
@@ -198,7 +224,7 @@ local gzFile gz_open (path, mode, fd)
*/
} else {
check_header(s); /* skip the .gz header */
- s->start = ftell(s->file) - s->stream.avail_in;
+ s->start = FTELL(s->file) - s->stream.avail_in;
}
return (gzFile)s;
@@ -211,7 +237,17 @@ gzFile ZEXPORT gzopen (path, mode)
const char *path;
const char *mode;
{
- return gz_open (path, mode, -1);
+ return gz_open (path, mode, -1, 0);
+}
+
+/* ===========================================================================
+ Opens a gzip (.gz) file for reading or writing for 64-bit offsets
+*/
+gzFile ZEXPORT gzopen64 (path, mode)
+ const char *path;
+ const char *mode;
+{
+ return gz_open (path, mode, -1, 1);
}
/* ===========================================================================
@@ -227,7 +263,7 @@ gzFile ZEXPORT gzdopen (fd, mode)
if (fd < 0) return (gzFile)Z_NULL;
sprintf(name, "<fd:%d>", fd); /* for debugging */
- return gz_open (name, mode, fd);
+ return gz_open (name, mode, fd, 0);
}
/* ===========================================================================
@@ -767,10 +803,17 @@ int ZEXPORT gzflush (file, flush)
SEEK_END is not implemented, returns error.
In this version of the library, gzseek can be extremely slow.
*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
+#ifdef _LARGEFILE64_SOURCE
+local off64_t gz_seek (file, offset, whence, use64)
+ gzFile file;
+ off64_t offset;
+#else
+local z_off_t gz_seek (file, offset, whence, use64)
gzFile file;
z_off_t offset;
+#endif
int whence;
+ int use64;
{
gz_stream *s = (gz_stream*)file;
@@ -819,7 +862,13 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
s->back = EOF;
s->stream.avail_in = 0;
s->stream.next_in = s->inbuf;
- if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
+#ifdef _LARGEFILE64_SOURCE
+ if ((use64 ? fseeko64(s->file, offset, SEEK_SET) :
+ FSEEK(s->file, offset, SEEK_SET)) < 0)
+ return -1L;
+#else
+ if (FSEEK(s->file, offset, SEEK_SET) < 0) return -1L;
+#endif
s->in = s->out = offset;
return offset;
@@ -855,6 +904,35 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
}
/* ===========================================================================
+ Define external functions gzseek() and gzseek64() using local gz_seek().
+*/
+z_off_t ZEXPORT gzseek (file, offset, whence)
+ gzFile file;
+ z_off_t offset;
+ int whence;
+{
+ return (z_off_t)gz_seek(file, offset, whence, 0);
+}
+
+#ifdef _LARGEFILE64_SOURCE
+off64_t ZEXPORT gzseek64 (file, offset, whence)
+ gzFile file;
+ off64_t offset;
+ int whence;
+{
+ return gz_seek(file, offset, whence, 1);
+}
+#else
+z_off_t ZEXPORT gzseek64 (file, offset, whence)
+ gzFile file;
+ z_off_t offset;
+ int whence;
+{
+ return gz_seek(file, offset, whence, 0);
+}
+#endif
+
+/* ===========================================================================
Rewinds input file.
*/
int ZEXPORT gzrewind (file)
@@ -873,7 +951,7 @@ int ZEXPORT gzrewind (file)
if (!s->transparent) (void)inflateReset(&s->stream);
s->in = 0;
s->out = 0;
- return fseek(s->file, s->start, SEEK_SET);
+ return FSEEK(s->file, s->start, SEEK_SET);
}
/* ===========================================================================
@@ -888,6 +966,19 @@ z_off_t ZEXPORT gztell (file)
}
/* ===========================================================================
+ 64-bit version
+*/
+#ifdef _LARGEFILE64_SOURCE
+off64_t ZEXPORT gztell64 (file)
+#else
+z_off_t ZEXPORT gztell64 (file)
+#endif
+ gzFile file;
+{
+ return gzseek64(file, 0L, SEEK_CUR);
+}
+
+/* ===========================================================================
Returns 1 when EOF has previously been detected reading the given
input stream, otherwise zero.
*/
diff --git a/infback.c b/infback.c
index 455dbc9..be0b3dc 100644
--- a/infback.c
+++ b/infback.c
@@ -1,5 +1,5 @@
/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -253,7 +253,7 @@ void FAR *out_desc;
unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -389,19 +389,19 @@ void FAR *out_desc;
state->have = 0;
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
state->mode = BAD;
@@ -411,16 +411,16 @@ void FAR *out_desc;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -474,28 +474,28 @@ void FAR *out_desc;
/* get a literal, length, or end-of-block code */
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->lencode[last.val +
+ here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
+ DROPBITS(here.bits);
+ state->length = (unsigned)here.val;
/* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ if (here.op == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
ROOM();
*put++ = (unsigned char)(state->length);
left--;
@@ -504,21 +504,21 @@ void FAR *out_desc;
}
/* process end of block */
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
/* invalid code */
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
/* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
NEEDBITS(state->extra);
state->length += BITS(state->extra);
@@ -528,30 +528,30 @@ void FAR *out_desc;
/* get distance code */
for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->distcode[last.val +
+ here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
- state->offset = (unsigned)this.val;
+ state->offset = (unsigned)here.val;
/* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
diff --git a/inffast.c b/inffast.c
index bbee92e..0b919bb 100644
--- a/inffast.c
+++ b/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -87,7 +87,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
code const FAR *dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
+ code here; /* retrieved table entry */
unsigned op; /* code bits, operation, extra bits, or */
/* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */
@@ -124,20 +124,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
- this = lcode[hold & lmask];
+ here = lcode[hold & lmask];
dolen:
- op = (unsigned)(this.bits);
+ op = (unsigned)(here.bits);
hold >>= op;
bits -= op;
- op = (unsigned)(this.op);
+ op = (unsigned)(here.op);
if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
+ "inflate: literal 0x%02x\n", here.val));
+ PUP(out) = (unsigned char)(here.val);
}
else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
+ len = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
@@ -155,14 +155,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
- this = dcode[hold & dmask];
+ here = dcode[hold & dmask];
dodist:
- op = (unsigned)(this.bits);
+ op = (unsigned)(here.bits);
hold >>= op;
bits -= op;
- op = (unsigned)(this.op);
+ op = (unsigned)(here.op);
if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
+ dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
@@ -187,9 +187,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (dist > op) { /* see if copy from window */
op = dist - op; /* distance back in window */
if (op > whave) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
+ if (state->sane) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ if (len <= op - whave) {
+ do {
+ PUP(out) = 0;
+ } while (--len);
+ continue;
+ }
+ len -= op - whave;
+ do {
+ PUP(out) = 0;
+ } while (--op > whave);
+ if (op == 0) {
+ from = out - dist;
+ do {
+ PUP(out) = PUP(from);
+ } while (--len);
+ continue;
+ }
+#endif
}
from = window - OFF;
if (write == 0) { /* very common case */
@@ -259,7 +280,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
+ here = dcode[here.val + (hold & ((1U << op) - 1))];
goto dodist;
}
else {
@@ -269,7 +290,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
+ here = lcode[here.val + (hold & ((1U << op) - 1))];
goto dolen;
}
else if (op & 32) { /* end-of-block */
diff --git a/inflate.c b/inflate.c
index 792fdee..d3c718c 100644
--- a/inflate.c
+++ b/inflate.c
@@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2006 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -121,6 +121,7 @@ z_streamp strm;
state->hold = 0;
state->bits = 0;
state->lencode = state->distcode = state->next = state->codes;
+ state->sane = 1;
Tracev((stderr, "inflate: reset\n"));
return Z_OK;
}
@@ -564,7 +565,7 @@ int flush;
unsigned in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -876,19 +877,19 @@ int flush;
case CODELENS:
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
state->mode = BAD;
@@ -898,16 +899,16 @@ int flush;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -955,40 +956,40 @@ int flush;
break;
}
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->lencode[last.val +
+ here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ DROPBITS(here.bits);
+ state->length = (unsigned)here.val;
+ if ((int)(here.op) == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
state->mode = LIT;
break;
}
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT;
case LENEXT:
if (state->extra) {
@@ -1000,28 +1001,28 @@ int flush;
state->mode = DIST;
case DIST:
for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->distcode[last.val +
+ here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
+ state->offset = (unsigned)here.val;
+ state->extra = (unsigned)(here.op) & 15;
state->mode = DISTEXT;
case DISTEXT:
if (state->extra) {
@@ -1036,11 +1037,6 @@ int flush;
break;
}
#endif
- if (state->offset > state->whave + out - left) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
Tracevv((stderr, "inflate: distance %u\n", state->offset));
state->mode = MATCH;
case MATCH:
@@ -1048,6 +1044,26 @@ int flush;
copy = out - left;
if (state->offset > copy) { /* copy from window */
copy = state->offset - copy;
+ if (copy > state->whave) {
+ if (state->sane) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ Trace((stderr, "inflate.c too far\n"));
+ copy -= state->whave;
+ if (copy > state->length) copy = state->length;
+ if (copy > left) copy = left;
+ left -= copy;
+ state->length -= copy;
+ do {
+ *put++ = 0;
+ } while (--copy);
+ if (state->length == 0) state->mode = LEN;
+ break;
+#endif
+ }
if (copy > state->write) {
copy -= state->write;
from = state->window + (state->wsize - copy);
@@ -1366,3 +1382,20 @@ z_streamp source;
dest->state = (struct internal_state FAR *)copy;
return Z_OK;
}
+
+int ZEXPORT inflateUndermine(strm, subvert)
+z_streamp strm;
+int subvert;
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ state->sane = !subvert;
+ return Z_OK;
+#else
+ state->sane = 1;
+ return Z_DATA_ERROR;
+#endif
+}
diff --git a/inflate.h b/inflate.h
index d90c6bc..d54a868 100644
--- a/inflate.h
+++ b/inflate.h
@@ -112,4 +112,5 @@ struct inflate_state {
unsigned short lens[320]; /* temporary storage for code lengths */
unsigned short work[288]; /* work area for code table building */
code codes[ENOUGH]; /* space for code tables */
+ int sane; /* if false, allow invalid distance too far */
};
diff --git a/inftrees.c b/inftrees.c
index 4ae6502..fb8d843 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.3.2 Copyright 1995-2006 Mark Adler ";
+ " inflate 1.2.3.3 Copyright 1995-2006 Mark Adler ";
/*
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
@@ -50,7 +50,7 @@ unsigned short FAR *work;
unsigned fill; /* index for replicating entries */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
+ code here; /* table entry for duplication */
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
@@ -62,7 +62,7 @@ unsigned short FAR *work;
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 */
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, 192, 204};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 203};
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,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -115,11 +115,11 @@ unsigned short FAR *work;
if (count[max] != 0) break;
if (root > max) root = max;
if (max == 0) { /* no symbols to code at all */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)1;
- this.val = (unsigned short)0;
- *(*table)++ = this; /* make a table to force an error */
- *(*table)++ = this;
+ here.op = (unsigned char)64; /* invalid code marker */
+ here.bits = (unsigned char)1;
+ here.val = (unsigned short)0;
+ *(*table)++ = here; /* make a table to force an error */
+ *(*table)++ = here;
*bits = 1;
return 0; /* no symbols, but wait for decoding to report error */
}
@@ -215,18 +215,18 @@ unsigned short FAR *work;
/* process all codes and make table entries */
for (;;) {
/* create table entry */
- this.bits = (unsigned char)(len - drop);
+ here.bits = (unsigned char)(len - drop);
if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
+ here.op = (unsigned char)0;
+ here.val = work[sym];
}
else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
+ here.op = (unsigned char)(extra[work[sym]]);
+ here.val = base[work[sym]];
}
else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
+ here.op = (unsigned char)(32 + 64); /* end of block */
+ here.val = 0;
}
/* replicate for those indices with low len bits equal to huff */
@@ -235,7 +235,7 @@ unsigned short FAR *work;
min = fill; /* save offset to next table */
do {
fill -= incr;
- next[(huff >> drop) + fill] = this;
+ next[(huff >> drop) + fill] = here;
} while (fill != 0);
/* backwards increment the len-bit code huff */
@@ -295,20 +295,20 @@ unsigned short FAR *work;
through high index bits. When the current sub-table is filled, the loop
drops back to the root table to fill in any remaining entries there.
*/
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
+ here.op = (unsigned char)64; /* invalid code marker */
+ here.bits = (unsigned char)(len - drop);
+ here.val = (unsigned short)0;
while (huff != 0) {
/* when done with sub-table, drop back to root table */
if (drop != 0 && (huff & mask) != low) {
drop = 0;
len = root;
next = *table;
- this.bits = (unsigned char)len;
+ here.bits = (unsigned char)len;
}
/* put invalid code marker in table */
- next[huff >> drop] = this;
+ next[huff >> drop] = here;
/* backwards increment the len-bit code huff */
incr = 1U << (len - 1);
diff --git a/qnx/package.qpg b/qnx/package.qpg
index b7e8bf7..be5d5c1 100644
--- a/qnx/package.qpg
+++ b/qnx/package.qpg
@@ -25,10 +25,10 @@
<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.3.2" 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.3.2"/>
- <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3.2"/>
- <QPG:Add file="../libz.so.1.2.3.2" install="/opt/lib/" component="slib"/>
+ <QPG:Add file="../libz.so.1.2.3.3" 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.3.3"/>
+ <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3.3"/>
+ <QPG:Add file="../libz.so.1.2.3.3" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
@@ -63,7 +63,7 @@
</QPM:ProductDescription>
<QPM:ReleaseDescription>
- <QPM:ReleaseVersion>1.2.3.2</QPM:ReleaseVersion>
+ <QPM:ReleaseVersion>1.2.3.3</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
diff --git a/zlib.3 b/zlib.3
index 8d22c3f..b83f234 100644
--- a/zlib.3
+++ b/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "xx August 2006"
+.TH ZLIB 3 "2 October 2006"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -133,8 +133,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
-Version 1.2.3.2
-Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org)
+Version 1.2.3.3
+Copyright (C) 1995-2006 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"
diff --git a/zlib.h b/zlib.h
index 44ae5e9..bb164c0 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.3.2, September 3rd, 2006
+ version 1.2.3.3, October 2nd, 2006
Copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler
@@ -37,8 +37,8 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.3.2"
-#define ZLIB_VERNUM 0x1232
+#define ZLIB_VERSION "1.2.3.3"
+#define ZLIB_VERNUM 0x1233
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 3
@@ -1077,8 +1077,9 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
typedef voidp gzFile;
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb") but can also include a compression level
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
@@ -1192,9 +1193,10 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
degrade compression.
*/
+/*
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
z_off_t offset, int whence));
-/*
+
Sets the starting position for the next gzread or gzwrite on the
given compressed file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
@@ -1217,8 +1219,9 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
*/
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
/*
+ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+
Returns the starting position for the next gzread or gzwrite on the
given compressed file. This position represents a number of bytes in the
uncompressed data stream.
@@ -1289,9 +1292,10 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error();
*/
+/*
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
z_off_t len2));
-/*
+
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
@@ -1314,9 +1318,9 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+/*
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-/*
Combine two CRC-32 check values into one. For two sequences of bytes,
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
@@ -1357,13 +1361,36 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
inflateBackInit_((strm), (windowBits), (window), \
ZLIB_VERSION, sizeof(z_stream))
+#ifdef _LARGEFILE64_SOURCE
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int));
+ ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t));
+#endif
+
+#if _FILE_OFFSET_BITS == 64
+# define gzopen gzopen64
+# define gzseek gzseek64
+# define gztell gztell64
+# define adler32_combine adler32_combine64
+# define crc32_combine crc32_combine64
+#else
+ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif
ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
+ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
#ifdef __cplusplus
}
diff --git a/zutil.h b/zutil.h
index 3568c44..32e9c89 100644
--- a/zutil.h
+++ b/zutil.h
@@ -177,6 +177,12 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
+#ifdef _LARGEFILE64_SOURCE
+# define F_OPEN64(name, mode) fopen64((name), (mode))
+#else
+# define F_OPEN64(name, mode) fopen((name), (mode))
+#endif
+
/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)