modules/zlib/src/FAQ

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/zlib/src/FAQ	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,368 @@
     1.4 +
     1.5 +                Frequently Asked Questions about zlib
     1.6 +
     1.7 +
     1.8 +If your question is not there, please check the zlib home page
     1.9 +http://zlib.net/ which may have more recent information.
    1.10 +The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
    1.11 +
    1.12 +
    1.13 + 1. Is zlib Y2K-compliant?
    1.14 +
    1.15 +    Yes. zlib doesn't handle dates.
    1.16 +
    1.17 + 2. Where can I get a Windows DLL version?
    1.18 +
    1.19 +    The zlib sources can be compiled without change to produce a DLL.  See the
    1.20 +    file win32/DLL_FAQ.txt in the zlib distribution.  Pointers to the
    1.21 +    precompiled DLL are found in the zlib web site at http://zlib.net/ .
    1.22 +
    1.23 + 3. Where can I get a Visual Basic interface to zlib?
    1.24 +
    1.25 +    See
    1.26 +        * http://marknelson.us/1997/01/01/zlib-engine/
    1.27 +        * win32/DLL_FAQ.txt in the zlib distribution
    1.28 +
    1.29 + 4. compress() returns Z_BUF_ERROR.
    1.30 +
    1.31 +    Make sure that before the call of compress(), the length of the compressed
    1.32 +    buffer is equal to the available size of the compressed buffer and not
    1.33 +    zero.  For Visual Basic, check that this parameter is passed by reference
    1.34 +    ("as any"), not by value ("as long").
    1.35 +
    1.36 + 5. deflate() or inflate() returns Z_BUF_ERROR.
    1.37 +
    1.38 +    Before making the call, make sure that avail_in and avail_out are not zero.
    1.39 +    When setting the parameter flush equal to Z_FINISH, also make sure that
    1.40 +    avail_out is big enough to allow processing all pending input.  Note that a
    1.41 +    Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
    1.42 +    made with more input or output space.  A Z_BUF_ERROR may in fact be
    1.43 +    unavoidable depending on how the functions are used, since it is not
    1.44 +    possible to tell whether or not there is more output pending when
    1.45 +    strm.avail_out returns with zero.  See http://zlib.net/zlib_how.html for a
    1.46 +    heavily annotated example.
    1.47 +
    1.48 + 6. Where's the zlib documentation (man pages, etc.)?
    1.49 +
    1.50 +    It's in zlib.h .  Examples of zlib usage are in the files test/example.c
    1.51 +    and test/minigzip.c, with more in examples/ .
    1.52 +
    1.53 + 7. Why don't you use GNU autoconf or libtool or ...?
    1.54 +
    1.55 +    Because we would like to keep zlib as a very small and simple package.
    1.56 +    zlib is rather portable and doesn't need much configuration.
    1.57 +
    1.58 + 8. I found a bug in zlib.
    1.59 +
    1.60 +    Most of the time, such problems are due to an incorrect usage of zlib.
    1.61 +    Please try to reproduce the problem with a small program and send the
    1.62 +    corresponding source to us at zlib@gzip.org .  Do not send multi-megabyte
    1.63 +    data files without prior agreement.
    1.64 +
    1.65 + 9. Why do I get "undefined reference to gzputc"?
    1.66 +
    1.67 +    If "make test" produces something like
    1.68 +
    1.69 +       example.o(.text+0x154): undefined reference to `gzputc'
    1.70 +
    1.71 +    check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
    1.72 +    /usr/X11R6/lib. Remove any old versions, then do "make install".
    1.73 +
    1.74 +10. I need a Delphi interface to zlib.
    1.75 +
    1.76 +    See the contrib/delphi directory in the zlib distribution.
    1.77 +
    1.78 +11. Can zlib handle .zip archives?
    1.79 +
    1.80 +    Not by itself, no.  See the directory contrib/minizip in the zlib
    1.81 +    distribution.
    1.82 +
    1.83 +12. Can zlib handle .Z files?
    1.84 +
    1.85 +    No, sorry.  You have to spawn an uncompress or gunzip subprocess, or adapt
    1.86 +    the code of uncompress on your own.
    1.87 +
    1.88 +13. How can I make a Unix shared library?
    1.89 +
    1.90 +    By default a shared (and a static) library is built for Unix.  So:
    1.91 +
    1.92 +    make distclean
    1.93 +    ./configure
    1.94 +    make
    1.95 +
    1.96 +14. How do I install a shared zlib library on Unix?
    1.97 +
    1.98 +    After the above, then:
    1.99 +
   1.100 +    make install
   1.101 +
   1.102 +    However, many flavors of Unix come with a shared zlib already installed.
   1.103 +    Before going to the trouble of compiling a shared version of zlib and
   1.104 +    trying to install it, you may want to check if it's already there!  If you
   1.105 +    can #include <zlib.h>, it's there.  The -lz option will probably link to
   1.106 +    it.  You can check the version at the top of zlib.h or with the
   1.107 +    ZLIB_VERSION symbol defined in zlib.h .
   1.108 +
   1.109 +15. I have a question about OttoPDF.
   1.110 +
   1.111 +    We are not the authors of OttoPDF. The real author is on the OttoPDF web
   1.112 +    site: Joel Hainley, jhainley@myndkryme.com.
   1.113 +
   1.114 +16. Can zlib decode Flate data in an Adobe PDF file?
   1.115 +
   1.116 +    Yes. See http://www.pdflib.com/ . To modify PDF forms, see
   1.117 +    http://sourceforge.net/projects/acroformtool/ .
   1.118 +
   1.119 +17. Why am I getting this "register_frame_info not found" error on Solaris?
   1.120 +
   1.121 +    After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
   1.122 +    generates an error such as:
   1.123 +
   1.124 +        ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
   1.125 +        symbol __register_frame_info: referenced symbol not found
   1.126 +
   1.127 +    The symbol __register_frame_info is not part of zlib, it is generated by
   1.128 +    the C compiler (cc or gcc).  You must recompile applications using zlib
   1.129 +    which have this problem.  This problem is specific to Solaris.  See
   1.130 +    http://www.sunfreeware.com for Solaris versions of zlib and applications
   1.131 +    using zlib.
   1.132 +
   1.133 +18. Why does gzip give an error on a file I make with compress/deflate?
   1.134 +
   1.135 +    The compress and deflate functions produce data in the zlib format, which
   1.136 +    is different and incompatible with the gzip format.  The gz* functions in
   1.137 +    zlib on the other hand use the gzip format.  Both the zlib and gzip formats
   1.138 +    use the same compressed data format internally, but have different headers
   1.139 +    and trailers around the compressed data.
   1.140 +
   1.141 +19. Ok, so why are there two different formats?
   1.142 +
   1.143 +    The gzip format was designed to retain the directory information about a
   1.144 +    single file, such as the name and last modification date.  The zlib format
   1.145 +    on the other hand was designed for in-memory and communication channel
   1.146 +    applications, and has a much more compact header and trailer and uses a
   1.147 +    faster integrity check than gzip.
   1.148 +
   1.149 +20. Well that's nice, but how do I make a gzip file in memory?
   1.150 +
   1.151 +    You can request that deflate write the gzip format instead of the zlib
   1.152 +    format using deflateInit2().  You can also request that inflate decode the
   1.153 +    gzip format using inflateInit2().  Read zlib.h for more details.
   1.154 +
   1.155 +21. Is zlib thread-safe?
   1.156 +
   1.157 +    Yes.  However any library routines that zlib uses and any application-
   1.158 +    provided memory allocation routines must also be thread-safe.  zlib's gz*
   1.159 +    functions use stdio library routines, and most of zlib's functions use the
   1.160 +    library memory allocation routines by default.  zlib's *Init* functions
   1.161 +    allow for the application to provide custom memory allocation routines.
   1.162 +
   1.163 +    Of course, you should only operate on any given zlib or gzip stream from a
   1.164 +    single thread at a time.
   1.165 +
   1.166 +22. Can I use zlib in my commercial application?
   1.167 +
   1.168 +    Yes.  Please read the license in zlib.h.
   1.169 +
   1.170 +23. Is zlib under the GNU license?
   1.171 +
   1.172 +    No.  Please read the license in zlib.h.
   1.173 +
   1.174 +24. The license says that altered source versions must be "plainly marked". So
   1.175 +    what exactly do I need to do to meet that requirement?
   1.176 +
   1.177 +    You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h.  In
   1.178 +    particular, the final version number needs to be changed to "f", and an
   1.179 +    identification string should be appended to ZLIB_VERSION.  Version numbers
   1.180 +    x.x.x.f are reserved for modifications to zlib by others than the zlib
   1.181 +    maintainers.  For example, if the version of the base zlib you are altering
   1.182 +    is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
   1.183 +    ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3".  You can also
   1.184 +    update the version strings in deflate.c and inftrees.c.
   1.185 +
   1.186 +    For altered source distributions, you should also note the origin and
   1.187 +    nature of the changes in zlib.h, as well as in ChangeLog and README, along
   1.188 +    with the dates of the alterations.  The origin should include at least your
   1.189 +    name (or your company's name), and an email address to contact for help or
   1.190 +    issues with the library.
   1.191 +
   1.192 +    Note that distributing a compiled zlib library along with zlib.h and
   1.193 +    zconf.h is also a source distribution, and so you should change
   1.194 +    ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
   1.195 +    in zlib.h as you would for a full source distribution.
   1.196 +
   1.197 +25. Will zlib work on a big-endian or little-endian architecture, and can I
   1.198 +    exchange compressed data between them?
   1.199 +
   1.200 +    Yes and yes.
   1.201 +
   1.202 +26. Will zlib work on a 64-bit machine?
   1.203 +
   1.204 +    Yes.  It has been tested on 64-bit machines, and has no dependence on any
   1.205 +    data types being limited to 32-bits in length.  If you have any
   1.206 +    difficulties, please provide a complete problem report to zlib@gzip.org
   1.207 +
   1.208 +27. Will zlib decompress data from the PKWare Data Compression Library?
   1.209 +
   1.210 +    No.  The PKWare DCL uses a completely different compressed data format than
   1.211 +    does PKZIP and zlib.  However, you can look in zlib's contrib/blast
   1.212 +    directory for a possible solution to your problem.
   1.213 +
   1.214 +28. Can I access data randomly in a compressed stream?
   1.215 +
   1.216 +    No, not without some preparation.  If when compressing you periodically use
   1.217 +    Z_FULL_FLUSH, carefully write all the pending data at those points, and
   1.218 +    keep an index of those locations, then you can start decompression at those
   1.219 +    points.  You have to be careful to not use Z_FULL_FLUSH too often, since it
   1.220 +    can significantly degrade compression.  Alternatively, you can scan a
   1.221 +    deflate stream once to generate an index, and then use that index for
   1.222 +    random access.  See examples/zran.c .
   1.223 +
   1.224 +29. Does zlib work on MVS, OS/390, CICS, etc.?
   1.225 +
   1.226 +    It has in the past, but we have not heard of any recent evidence.  There
   1.227 +    were working ports of zlib 1.1.4 to MVS, but those links no longer work.
   1.228 +    If you know of recent, successful applications of zlib on these operating
   1.229 +    systems, please let us know.  Thanks.
   1.230 +
   1.231 +30. Is there some simpler, easier to read version of inflate I can look at to
   1.232 +    understand the deflate format?
   1.233 +
   1.234 +    First off, you should read RFC 1951.  Second, yes.  Look in zlib's
   1.235 +    contrib/puff directory.
   1.236 +
   1.237 +31. Does zlib infringe on any patents?
   1.238 +
   1.239 +    As far as we know, no.  In fact, that was originally the whole point behind
   1.240 +    zlib.  Look here for some more information:
   1.241 +
   1.242 +    http://www.gzip.org/#faq11
   1.243 +
   1.244 +32. Can zlib work with greater than 4 GB of data?
   1.245 +
   1.246 +    Yes.  inflate() and deflate() will process any amount of data correctly.
   1.247 +    Each call of inflate() or deflate() is limited to input and output chunks
   1.248 +    of the maximum value that can be stored in the compiler's "unsigned int"
   1.249 +    type, but there is no limit to the number of chunks.  Note however that the
   1.250 +    strm.total_in and strm_total_out counters may be limited to 4 GB.  These
   1.251 +    counters are provided as a convenience and are not used internally by
   1.252 +    inflate() or deflate().  The application can easily set up its own counters
   1.253 +    updated after each call of inflate() or deflate() to count beyond 4 GB.
   1.254 +    compress() and uncompress() may be limited to 4 GB, since they operate in a
   1.255 +    single call.  gzseek() and gztell() may be limited to 4 GB depending on how
   1.256 +    zlib is compiled.  See the zlibCompileFlags() function in zlib.h.
   1.257 +
   1.258 +    The word "may" appears several times above since there is a 4 GB limit only
   1.259 +    if the compiler's "long" type is 32 bits.  If the compiler's "long" type is
   1.260 +    64 bits, then the limit is 16 exabytes.
   1.261 +
   1.262 +33. Does zlib have any security vulnerabilities?
   1.263 +
   1.264 +    The only one that we are aware of is potentially in gzprintf().  If zlib is
   1.265 +    compiled to use sprintf() or vsprintf(), then there is no protection
   1.266 +    against a buffer overflow of an 8K string space (or other value as set by
   1.267 +    gzbuffer()), other than the caller of gzprintf() assuring that the output
   1.268 +    will not exceed 8K.  On the other hand, if zlib is compiled to use
   1.269 +    snprintf() or vsnprintf(), which should normally be the case, then there is
   1.270 +    no vulnerability.  The ./configure script will display warnings if an
   1.271 +    insecure variation of sprintf() will be used by gzprintf().  Also the
   1.272 +    zlibCompileFlags() function will return information on what variant of
   1.273 +    sprintf() is used by gzprintf().
   1.274 +
   1.275 +    If you don't have snprintf() or vsnprintf() and would like one, you can
   1.276 +    find a portable implementation here:
   1.277 +
   1.278 +        http://www.ijs.si/software/snprintf/
   1.279 +
   1.280 +    Note that you should be using the most recent version of zlib.  Versions
   1.281 +    1.1.3 and before were subject to a double-free vulnerability, and versions
   1.282 +    1.2.1 and 1.2.2 were subject to an access exception when decompressing
   1.283 +    invalid compressed data.
   1.284 +
   1.285 +34. Is there a Java version of zlib?
   1.286 +
   1.287 +    Probably what you want is to use zlib in Java. zlib is already included
   1.288 +    as part of the Java SDK in the java.util.zip package. If you really want
   1.289 +    a version of zlib written in the Java language, look on the zlib home
   1.290 +    page for links: http://zlib.net/ .
   1.291 +
   1.292 +35. I get this or that compiler or source-code scanner warning when I crank it
   1.293 +    up to maximally-pedantic. Can't you guys write proper code?
   1.294 +
   1.295 +    Many years ago, we gave up attempting to avoid warnings on every compiler
   1.296 +    in the universe.  It just got to be a waste of time, and some compilers
   1.297 +    were downright silly as well as contradicted each other.  So now, we simply
   1.298 +    make sure that the code always works.
   1.299 +
   1.300 +36. Valgrind (or some similar memory access checker) says that deflate is
   1.301 +    performing a conditional jump that depends on an uninitialized value.
   1.302 +    Isn't that a bug?
   1.303 +
   1.304 +    No.  That is intentional for performance reasons, and the output of deflate
   1.305 +    is not affected.  This only started showing up recently since zlib 1.2.x
   1.306 +    uses malloc() by default for allocations, whereas earlier versions used
   1.307 +    calloc(), which zeros out the allocated memory.  Even though the code was
   1.308 +    correct, versions 1.2.4 and later was changed to not stimulate these
   1.309 +    checkers.
   1.310 +
   1.311 +37. Will zlib read the (insert any ancient or arcane format here) compressed
   1.312 +    data format?
   1.313 +
   1.314 +    Probably not. Look in the comp.compression FAQ for pointers to various
   1.315 +    formats and associated software.
   1.316 +
   1.317 +38. How can I encrypt/decrypt zip files with zlib?
   1.318 +
   1.319 +    zlib doesn't support encryption.  The original PKZIP encryption is very
   1.320 +    weak and can be broken with freely available programs.  To get strong
   1.321 +    encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
   1.322 +    compression.  For PKZIP compatible "encryption", look at
   1.323 +    http://www.info-zip.org/
   1.324 +
   1.325 +39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
   1.326 +
   1.327 +    "gzip" is the gzip format, and "deflate" is the zlib format.  They should
   1.328 +    probably have called the second one "zlib" instead to avoid confusion with
   1.329 +    the raw deflate compressed data format.  While the HTTP 1.1 RFC 2616
   1.330 +    correctly points to the zlib specification in RFC 1950 for the "deflate"
   1.331 +    transfer encoding, there have been reports of servers and browsers that
   1.332 +    incorrectly produce or expect raw deflate data per the deflate
   1.333 +    specification in RFC 1951, most notably Microsoft.  So even though the
   1.334 +    "deflate" transfer encoding using the zlib format would be the more
   1.335 +    efficient approach (and in fact exactly what the zlib format was designed
   1.336 +    for), using the "gzip" transfer encoding is probably more reliable due to
   1.337 +    an unfortunate choice of name on the part of the HTTP 1.1 authors.
   1.338 +
   1.339 +    Bottom line: use the gzip format for HTTP 1.1 encoding.
   1.340 +
   1.341 +40. Does zlib support the new "Deflate64" format introduced by PKWare?
   1.342 +
   1.343 +    No.  PKWare has apparently decided to keep that format proprietary, since
   1.344 +    they have not documented it as they have previous compression formats.  In
   1.345 +    any case, the compression improvements are so modest compared to other more
   1.346 +    modern approaches, that it's not worth the effort to implement.
   1.347 +
   1.348 +41. I'm having a problem with the zip functions in zlib, can you help?
   1.349 +
   1.350 +    There are no zip functions in zlib.  You are probably using minizip by
   1.351 +    Giles Vollant, which is found in the contrib directory of zlib.  It is not
   1.352 +    part of zlib.  In fact none of the stuff in contrib is part of zlib.  The
   1.353 +    files in there are not supported by the zlib authors.  You need to contact
   1.354 +    the authors of the respective contribution for help.
   1.355 +
   1.356 +42. The match.asm code in contrib is under the GNU General Public License.
   1.357 +    Since it's part of zlib, doesn't that mean that all of zlib falls under the
   1.358 +    GNU GPL?
   1.359 +
   1.360 +    No.  The files in contrib are not part of zlib.  They were contributed by
   1.361 +    other authors and are provided as a convenience to the user within the zlib
   1.362 +    distribution.  Each item in contrib has its own license.
   1.363 +
   1.364 +43. Is zlib subject to export controls?  What is its ECCN?
   1.365 +
   1.366 +    zlib is not subject to export controls, and so is classified as EAR99.
   1.367 +
   1.368 +44. Can you please sign these lengthy legal documents and fax them back to us
   1.369 +    so that we can use your software in our product?
   1.370 +
   1.371 +    No. Go away. Shoo.

mercurial