kusano fc6ab3
kusano fc6ab3
                Frequently Asked Questions about zlib
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
If your question is not there, please check the zlib home page
kusano fc6ab3
http://zlib.net/ which may have more recent information.
kusano fc6ab3
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
 1. Is zlib Y2K-compliant?
kusano fc6ab3
kusano fc6ab3
    Yes. zlib doesn't handle dates.
kusano fc6ab3
kusano fc6ab3
 2. Where can I get a Windows DLL version?
kusano fc6ab3
kusano fc6ab3
    The zlib sources can be compiled without change to produce a DLL.  See the
kusano fc6ab3
    file win32/DLL_FAQ.txt in the zlib distribution.  Pointers to the
kusano fc6ab3
    precompiled DLL are found in the zlib web site at http://zlib.net/ .
kusano fc6ab3
kusano fc6ab3
 3. Where can I get a Visual Basic interface to zlib?
kusano fc6ab3
kusano fc6ab3
    See
kusano fc6ab3
        * http://marknelson.us/1997/01/01/zlib-engine/
kusano fc6ab3
        * win32/DLL_FAQ.txt in the zlib distribution
kusano fc6ab3
kusano fc6ab3
 4. compress() returns Z_BUF_ERROR.
kusano fc6ab3
kusano fc6ab3
    Make sure that before the call of compress(), the length of the compressed
kusano fc6ab3
    buffer is equal to the available size of the compressed buffer and not
kusano fc6ab3
    zero.  For Visual Basic, check that this parameter is passed by reference
kusano fc6ab3
    ("as any"), not by value ("as long").
kusano fc6ab3
kusano fc6ab3
 5. deflate() or inflate() returns Z_BUF_ERROR.
kusano fc6ab3
kusano fc6ab3
    Before making the call, make sure that avail_in and avail_out are not zero.
kusano fc6ab3
    When setting the parameter flush equal to Z_FINISH, also make sure that
kusano fc6ab3
    avail_out is big enough to allow processing all pending input.  Note that a
kusano fc6ab3
    Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
kusano fc6ab3
    made with more input or output space.  A Z_BUF_ERROR may in fact be
kusano fc6ab3
    unavoidable depending on how the functions are used, since it is not
kusano fc6ab3
    possible to tell whether or not there is more output pending when
kusano fc6ab3
    strm.avail_out returns with zero.  See http://zlib.net/zlib_how.html for a
kusano fc6ab3
    heavily annotated example.
kusano fc6ab3
kusano fc6ab3
 6. Where's the zlib documentation (man pages, etc.)?
kusano fc6ab3
kusano fc6ab3
    It's in zlib.h .  Examples of zlib usage are in the files test/example.c
kusano fc6ab3
    and test/minigzip.c, with more in examples/ .
kusano fc6ab3
kusano fc6ab3
 7. Why don't you use GNU autoconf or libtool or ...?
kusano fc6ab3
kusano fc6ab3
    Because we would like to keep zlib as a very small and simple package.
kusano fc6ab3
    zlib is rather portable and doesn't need much configuration.
kusano fc6ab3
kusano fc6ab3
 8. I found a bug in zlib.
kusano fc6ab3
kusano fc6ab3
    Most of the time, such problems are due to an incorrect usage of zlib.
kusano fc6ab3
    Please try to reproduce the problem with a small program and send the
kusano fc6ab3
    corresponding source to us at zlib@gzip.org .  Do not send multi-megabyte
kusano fc6ab3
    data files without prior agreement.
kusano fc6ab3
kusano fc6ab3
 9. Why do I get "undefined reference to gzputc"?
kusano fc6ab3
kusano fc6ab3
    If "make test" produces something like
kusano fc6ab3
kusano fc6ab3
       example.o(.text+0x154): undefined reference to `gzputc'
kusano fc6ab3
kusano fc6ab3
    check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
kusano fc6ab3
    /usr/X11R6/lib. Remove any old versions, then do "make install".
kusano fc6ab3
kusano fc6ab3
10. I need a Delphi interface to zlib.
kusano fc6ab3
kusano fc6ab3
    See the contrib/delphi directory in the zlib distribution.
kusano fc6ab3
kusano fc6ab3
11. Can zlib handle .zip archives?
kusano fc6ab3
kusano fc6ab3
    Not by itself, no.  See the directory contrib/minizip in the zlib
kusano fc6ab3
    distribution.
kusano fc6ab3
kusano fc6ab3
12. Can zlib handle .Z files?
kusano fc6ab3
kusano fc6ab3
    No, sorry.  You have to spawn an uncompress or gunzip subprocess, or adapt
kusano fc6ab3
    the code of uncompress on your own.
kusano fc6ab3
kusano fc6ab3
13. How can I make a Unix shared library?
kusano fc6ab3
kusano fc6ab3
    By default a shared (and a static) library is built for Unix.  So:
kusano fc6ab3
kusano fc6ab3
    make distclean
kusano fc6ab3
    ./configure
kusano fc6ab3
    make
kusano fc6ab3
kusano fc6ab3
14. How do I install a shared zlib library on Unix?
kusano fc6ab3
kusano fc6ab3
    After the above, then:
kusano fc6ab3
kusano fc6ab3
    make install
kusano fc6ab3
kusano fc6ab3
    However, many flavors of Unix come with a shared zlib already installed.
kusano fc6ab3
    Before going to the trouble of compiling a shared version of zlib and
kusano fc6ab3
    trying to install it, you may want to check if it's already there!  If you
kusano fc6ab3
    can #include <zlib.h>, it's there.  The -lz option will probably link to</zlib.h>
kusano fc6ab3
    it.  You can check the version at the top of zlib.h or with the
kusano fc6ab3
    ZLIB_VERSION symbol defined in zlib.h .
kusano fc6ab3
kusano fc6ab3
15. I have a question about OttoPDF.
kusano fc6ab3
kusano fc6ab3
    We are not the authors of OttoPDF. The real author is on the OttoPDF web
kusano fc6ab3
    site: Joel Hainley, jhainley@myndkryme.com.
kusano fc6ab3
kusano fc6ab3
16. Can zlib decode Flate data in an Adobe PDF file?
kusano fc6ab3
kusano fc6ab3
    Yes. See http://www.pdflib.com/ . To modify PDF forms, see
kusano fc6ab3
    http://sourceforge.net/projects/acroformtool/ .
kusano fc6ab3
kusano fc6ab3
17. Why am I getting this "register_frame_info not found" error on Solaris?
kusano fc6ab3
kusano fc6ab3
    After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
kusano fc6ab3
    generates an error such as:
kusano fc6ab3
kusano fc6ab3
        ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
kusano fc6ab3
        symbol __register_frame_info: referenced symbol not found
kusano fc6ab3
kusano fc6ab3
    The symbol __register_frame_info is not part of zlib, it is generated by
kusano fc6ab3
    the C compiler (cc or gcc).  You must recompile applications using zlib
kusano fc6ab3
    which have this problem.  This problem is specific to Solaris.  See
kusano fc6ab3
    http://www.sunfreeware.com for Solaris versions of zlib and applications
kusano fc6ab3
    using zlib.
kusano fc6ab3
kusano fc6ab3
18. Why does gzip give an error on a file I make with compress/deflate?
kusano fc6ab3
kusano fc6ab3
    The compress and deflate functions produce data in the zlib format, which
kusano fc6ab3
    is different and incompatible with the gzip format.  The gz* functions in
kusano fc6ab3
    zlib on the other hand use the gzip format.  Both the zlib and gzip formats
kusano fc6ab3
    use the same compressed data format internally, but have different headers
kusano fc6ab3
    and trailers around the compressed data.
kusano fc6ab3
kusano fc6ab3
19. Ok, so why are there two different formats?
kusano fc6ab3
kusano fc6ab3
    The gzip format was designed to retain the directory information about a
kusano fc6ab3
    single file, such as the name and last modification date.  The zlib format
kusano fc6ab3
    on the other hand was designed for in-memory and communication channel
kusano fc6ab3
    applications, and has a much more compact header and trailer and uses a
kusano fc6ab3
    faster integrity check than gzip.
kusano fc6ab3
kusano fc6ab3
20. Well that's nice, but how do I make a gzip file in memory?
kusano fc6ab3
kusano fc6ab3
    You can request that deflate write the gzip format instead of the zlib
kusano fc6ab3
    format using deflateInit2().  You can also request that inflate decode the
kusano fc6ab3
    gzip format using inflateInit2().  Read zlib.h for more details.
kusano fc6ab3
kusano fc6ab3
21. Is zlib thread-safe?
kusano fc6ab3
kusano fc6ab3
    Yes.  However any library routines that zlib uses and any application-
kusano fc6ab3
    provided memory allocation routines must also be thread-safe.  zlib's gz*
kusano fc6ab3
    functions use stdio library routines, and most of zlib's functions use the
kusano fc6ab3
    library memory allocation routines by default.  zlib's *Init* functions
kusano fc6ab3
    allow for the application to provide custom memory allocation routines.
kusano fc6ab3
kusano fc6ab3
    Of course, you should only operate on any given zlib or gzip stream from a
kusano fc6ab3
    single thread at a time.
kusano fc6ab3
kusano fc6ab3
22. Can I use zlib in my commercial application?
kusano fc6ab3
kusano fc6ab3
    Yes.  Please read the license in zlib.h.
kusano fc6ab3
kusano fc6ab3
23. Is zlib under the GNU license?
kusano fc6ab3
kusano fc6ab3
    No.  Please read the license in zlib.h.
kusano fc6ab3
kusano fc6ab3
24. The license says that altered source versions must be "plainly marked". So
kusano fc6ab3
    what exactly do I need to do to meet that requirement?
kusano fc6ab3
kusano fc6ab3
    You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h.  In
kusano fc6ab3
    particular, the final version number needs to be changed to "f", and an
kusano fc6ab3
    identification string should be appended to ZLIB_VERSION.  Version numbers
kusano fc6ab3
    x.x.x.f are reserved for modifications to zlib by others than the zlib
kusano fc6ab3
    maintainers.  For example, if the version of the base zlib you are altering
kusano fc6ab3
    is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
kusano fc6ab3
    ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3".  You can also
kusano fc6ab3
    update the version strings in deflate.c and inftrees.c.
kusano fc6ab3
kusano fc6ab3
    For altered source distributions, you should also note the origin and
kusano fc6ab3
    nature of the changes in zlib.h, as well as in ChangeLog and README, along
kusano fc6ab3
    with the dates of the alterations.  The origin should include at least your
kusano fc6ab3
    name (or your company's name), and an email address to contact for help or
kusano fc6ab3
    issues with the library.
kusano fc6ab3
kusano fc6ab3
    Note that distributing a compiled zlib library along with zlib.h and
kusano fc6ab3
    zconf.h is also a source distribution, and so you should change
kusano fc6ab3
    ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
kusano fc6ab3
    in zlib.h as you would for a full source distribution.
kusano fc6ab3
kusano fc6ab3
25. Will zlib work on a big-endian or little-endian architecture, and can I
kusano fc6ab3
    exchange compressed data between them?
kusano fc6ab3
kusano fc6ab3
    Yes and yes.
kusano fc6ab3
kusano fc6ab3
26. Will zlib work on a 64-bit machine?
kusano fc6ab3
kusano fc6ab3
    Yes.  It has been tested on 64-bit machines, and has no dependence on any
kusano fc6ab3
    data types being limited to 32-bits in length.  If you have any
kusano fc6ab3
    difficulties, please provide a complete problem report to zlib@gzip.org
kusano fc6ab3
kusano fc6ab3
27. Will zlib decompress data from the PKWare Data Compression Library?
kusano fc6ab3
kusano fc6ab3
    No.  The PKWare DCL uses a completely different compressed data format than
kusano fc6ab3
    does PKZIP and zlib.  However, you can look in zlib's contrib/blast
kusano fc6ab3
    directory for a possible solution to your problem.
kusano fc6ab3
kusano fc6ab3
28. Can I access data randomly in a compressed stream?
kusano fc6ab3
kusano fc6ab3
    No, not without some preparation.  If when compressing you periodically use
kusano fc6ab3
    Z_FULL_FLUSH, carefully write all the pending data at those points, and
kusano fc6ab3
    keep an index of those locations, then you can start decompression at those
kusano fc6ab3
    points.  You have to be careful to not use Z_FULL_FLUSH too often, since it
kusano fc6ab3
    can significantly degrade compression.  Alternatively, you can scan a
kusano fc6ab3
    deflate stream once to generate an index, and then use that index for
kusano fc6ab3
    random access.  See examples/zran.c .
kusano fc6ab3
kusano fc6ab3
29. Does zlib work on MVS, OS/390, CICS, etc.?
kusano fc6ab3
kusano fc6ab3
    It has in the past, but we have not heard of any recent evidence.  There
kusano fc6ab3
    were working ports of zlib 1.1.4 to MVS, but those links no longer work.
kusano fc6ab3
    If you know of recent, successful applications of zlib on these operating
kusano fc6ab3
    systems, please let us know.  Thanks.
kusano fc6ab3
kusano fc6ab3
30. Is there some simpler, easier to read version of inflate I can look at to
kusano fc6ab3
    understand the deflate format?
kusano fc6ab3
kusano fc6ab3
    First off, you should read RFC 1951.  Second, yes.  Look in zlib's
kusano fc6ab3
    contrib/puff directory.
kusano fc6ab3
kusano fc6ab3
31. Does zlib infringe on any patents?
kusano fc6ab3
kusano fc6ab3
    As far as we know, no.  In fact, that was originally the whole point behind
kusano fc6ab3
    zlib.  Look here for some more information:
kusano fc6ab3
kusano fc6ab3
    http://www.gzip.org/#faq11
kusano fc6ab3
kusano fc6ab3
32. Can zlib work with greater than 4 GB of data?
kusano fc6ab3
kusano fc6ab3
    Yes.  inflate() and deflate() will process any amount of data correctly.
kusano fc6ab3
    Each call of inflate() or deflate() is limited to input and output chunks
kusano fc6ab3
    of the maximum value that can be stored in the compiler's "unsigned int"
kusano fc6ab3
    type, but there is no limit to the number of chunks.  Note however that the
kusano fc6ab3
    strm.total_in and strm_total_out counters may be limited to 4 GB.  These
kusano fc6ab3
    counters are provided as a convenience and are not used internally by
kusano fc6ab3
    inflate() or deflate().  The application can easily set up its own counters
kusano fc6ab3
    updated after each call of inflate() or deflate() to count beyond 4 GB.
kusano fc6ab3
    compress() and uncompress() may be limited to 4 GB, since they operate in a
kusano fc6ab3
    single call.  gzseek() and gztell() may be limited to 4 GB depending on how
kusano fc6ab3
    zlib is compiled.  See the zlibCompileFlags() function in zlib.h.
kusano fc6ab3
kusano fc6ab3
    The word "may" appears several times above since there is a 4 GB limit only
kusano fc6ab3
    if the compiler's "long" type is 32 bits.  If the compiler's "long" type is
kusano fc6ab3
    64 bits, then the limit is 16 exabytes.
kusano fc6ab3
kusano fc6ab3
33. Does zlib have any security vulnerabilities?
kusano fc6ab3
kusano fc6ab3
    The only one that we are aware of is potentially in gzprintf().  If zlib is
kusano fc6ab3
    compiled to use sprintf() or vsprintf(), then there is no protection
kusano fc6ab3
    against a buffer overflow of an 8K string space (or other value as set by
kusano fc6ab3
    gzbuffer()), other than the caller of gzprintf() assuring that the output
kusano fc6ab3
    will not exceed 8K.  On the other hand, if zlib is compiled to use
kusano fc6ab3
    snprintf() or vsnprintf(), which should normally be the case, then there is
kusano fc6ab3
    no vulnerability.  The ./configure script will display warnings if an
kusano fc6ab3
    insecure variation of sprintf() will be used by gzprintf().  Also the
kusano fc6ab3
    zlibCompileFlags() function will return information on what variant of
kusano fc6ab3
    sprintf() is used by gzprintf().
kusano fc6ab3
kusano fc6ab3
    If you don't have snprintf() or vsnprintf() and would like one, you can
kusano fc6ab3
    find a portable implementation here:
kusano fc6ab3
kusano fc6ab3
        http://www.ijs.si/software/snprintf/
kusano fc6ab3
kusano fc6ab3
    Note that you should be using the most recent version of zlib.  Versions
kusano fc6ab3
    1.1.3 and before were subject to a double-free vulnerability, and versions
kusano fc6ab3
    1.2.1 and 1.2.2 were subject to an access exception when decompressing
kusano fc6ab3
    invalid compressed data.
kusano fc6ab3
kusano fc6ab3
34. Is there a Java version of zlib?
kusano fc6ab3
kusano fc6ab3
    Probably what you want is to use zlib in Java. zlib is already included
kusano fc6ab3
    as part of the Java SDK in the java.util.zip package. If you really want
kusano fc6ab3
    a version of zlib written in the Java language, look on the zlib home
kusano fc6ab3
    page for links: http://zlib.net/ .
kusano fc6ab3
kusano fc6ab3
35. I get this or that compiler or source-code scanner warning when I crank it
kusano fc6ab3
    up to maximally-pedantic. Can't you guys write proper code?
kusano fc6ab3
kusano fc6ab3
    Many years ago, we gave up attempting to avoid warnings on every compiler
kusano fc6ab3
    in the universe.  It just got to be a waste of time, and some compilers
kusano fc6ab3
    were downright silly as well as contradicted each other.  So now, we simply
kusano fc6ab3
    make sure that the code always works.
kusano fc6ab3
kusano fc6ab3
36. Valgrind (or some similar memory access checker) says that deflate is
kusano fc6ab3
    performing a conditional jump that depends on an uninitialized value.
kusano fc6ab3
    Isn't that a bug?
kusano fc6ab3
kusano fc6ab3
    No.  That is intentional for performance reasons, and the output of deflate
kusano fc6ab3
    is not affected.  This only started showing up recently since zlib 1.2.x
kusano fc6ab3
    uses malloc() by default for allocations, whereas earlier versions used
kusano fc6ab3
    calloc(), which zeros out the allocated memory.  Even though the code was
kusano fc6ab3
    correct, versions 1.2.4 and later was changed to not stimulate these
kusano fc6ab3
    checkers.
kusano fc6ab3
kusano fc6ab3
37. Will zlib read the (insert any ancient or arcane format here) compressed
kusano fc6ab3
    data format?
kusano fc6ab3
kusano fc6ab3
    Probably not. Look in the comp.compression FAQ for pointers to various
kusano fc6ab3
    formats and associated software.
kusano fc6ab3
kusano fc6ab3
38. How can I encrypt/decrypt zip files with zlib?
kusano fc6ab3
kusano fc6ab3
    zlib doesn't support encryption.  The original PKZIP encryption is very
kusano fc6ab3
    weak and can be broken with freely available programs.  To get strong
kusano fc6ab3
    encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
kusano fc6ab3
    compression.  For PKZIP compatible "encryption", look at
kusano fc6ab3
    http://www.info-zip.org/
kusano fc6ab3
kusano fc6ab3
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
kusano fc6ab3
kusano fc6ab3
    "gzip" is the gzip format, and "deflate" is the zlib format.  They should
kusano fc6ab3
    probably have called the second one "zlib" instead to avoid confusion with
kusano fc6ab3
    the raw deflate compressed data format.  While the HTTP 1.1 RFC 2616
kusano fc6ab3
    correctly points to the zlib specification in RFC 1950 for the "deflate"
kusano fc6ab3
    transfer encoding, there have been reports of servers and browsers that
kusano fc6ab3
    incorrectly produce or expect raw deflate data per the deflate
kusano fc6ab3
    specification in RFC 1951, most notably Microsoft.  So even though the
kusano fc6ab3
    "deflate" transfer encoding using the zlib format would be the more
kusano fc6ab3
    efficient approach (and in fact exactly what the zlib format was designed
kusano fc6ab3
    for), using the "gzip" transfer encoding is probably more reliable due to
kusano fc6ab3
    an unfortunate choice of name on the part of the HTTP 1.1 authors.
kusano fc6ab3
kusano fc6ab3
    Bottom line: use the gzip format for HTTP 1.1 encoding.
kusano fc6ab3
kusano fc6ab3
40. Does zlib support the new "Deflate64" format introduced by PKWare?
kusano fc6ab3
kusano fc6ab3
    No.  PKWare has apparently decided to keep that format proprietary, since
kusano fc6ab3
    they have not documented it as they have previous compression formats.  In
kusano fc6ab3
    any case, the compression improvements are so modest compared to other more
kusano fc6ab3
    modern approaches, that it's not worth the effort to implement.
kusano fc6ab3
kusano fc6ab3
41. I'm having a problem with the zip functions in zlib, can you help?
kusano fc6ab3
kusano fc6ab3
    There are no zip functions in zlib.  You are probably using minizip by
kusano fc6ab3
    Giles Vollant, which is found in the contrib directory of zlib.  It is not
kusano fc6ab3
    part of zlib.  In fact none of the stuff in contrib is part of zlib.  The
kusano fc6ab3
    files in there are not supported by the zlib authors.  You need to contact
kusano fc6ab3
    the authors of the respective contribution for help.
kusano fc6ab3
kusano fc6ab3
42. The match.asm code in contrib is under the GNU General Public License.
kusano fc6ab3
    Since it's part of zlib, doesn't that mean that all of zlib falls under the
kusano fc6ab3
    GNU GPL?
kusano fc6ab3
kusano fc6ab3
    No.  The files in contrib are not part of zlib.  They were contributed by
kusano fc6ab3
    other authors and are provided as a convenience to the user within the zlib
kusano fc6ab3
    distribution.  Each item in contrib has its own license.
kusano fc6ab3
kusano fc6ab3
43. Is zlib subject to export controls?  What is its ECCN?
kusano fc6ab3
kusano fc6ab3
    zlib is not subject to export controls, and so is classified as EAR99.
kusano fc6ab3
kusano fc6ab3
44. Can you please sign these lengthy legal documents and fax them back to us
kusano fc6ab3
    so that we can use your software in our product?
kusano fc6ab3
kusano fc6ab3
    No. Go away. Shoo.