Commits on Apr 20, 2018
  1. Fix a bug that can crash deflate on some input when using Z_FIXED.

    madler committed Apr 18, 2018
    This bug was reported by Danilo Ramos of Eideticom, Inc. It has
    lain in wait 13 years before being found! The bug was introduced
    in zlib, with the addition of the Z_FIXED option. That
    option forces the use of fixed Huffman codes. For rare inputs with
    a large number of distant matches, the pending buffer into which
    the compressed data is written can overwrite the distance symbol
    table which it overlays. That results in corrupted output due to
    invalid distances, and can result in out-of-bound accesses,
    crashing the application.
    The fix here combines the distance buffer and literal/length
    buffers into a single symbol buffer. Now three bytes of pending
    buffer space are opened up for each literal or length/distance
    pair consumed, instead of the previous two bytes. This assures
    that the pending buffer cannot overwrite the symbol table, since
    the maximum fixed code compressed length/distance is 31 bits, and
    since there are four bytes of pending space for every three bytes
    of symbol space.
Commits on Jan 31, 2018
Commits on Jan 9, 2018
Commits on Oct 13, 2017
  1. Remove old assembler code in which bugs have manifested.

    madler committed Oct 13, 2017
    In addition, there is not sufficient gain from the inflate
    assembler code to warrant its inclusion.
  2. Avoid an undefined behavior of memcpy() in _tr_stored_block().

    madler committed Oct 13, 2017
    Allegedly the behavior of memcpy() is undefined if the source
    pointer is NULL, even if the number of bytes to copy is zero.
Commits on Jun 3, 2017
  1. Avoid the use of ptrdiff_t.

    madler committed Jun 3, 2017
    This isn't the right type anyway to assure that it contains a
    pointer. That type would be intptr_t or uintptr_t. However the C99
    standard says that those types are optional, so their use would not
    be portable. This commit simply uses size_t or whatever configure
    decided to use for size_t. That would be the same length as
    ptrdiff_t, and so will work just as well. The code checks to see if
    the length of the type used is the same as the length of a void
    pointer, so there is already protection against the use of the
    wrong type. The use of size_t (or ptrdiff_t) will almost always
    work, as all modern architectures have an array size that is the
    same as the pointer size. Only old segmented architectures would
    have to fall back to the slower CRC-32 calculation, where the
    amount of memory that can be accessed is larger than the maximum
    array size.
Commits on Apr 16, 2017
  1. Handle case where inflateSync used when header never processed.

    madler committed Apr 16, 2017
    If zlib and/or gzip header processing was requested, but a header
    was never provided and inflateSync was used successfully, then the
    inflate state would be inconsistent, trying to compute a check
    value but with no flags set. This commit sets the inflate mode to
    raw in this case, since there is no other assumption that can be
    made if a header was requested but never seen.
Commits on Mar 30, 2017
Commits on Feb 19, 2017
Commits on Feb 16, 2017
  1. Small speedup to inflate [psumbera].

    madler committed Feb 12, 2017
    Seeing a few percent speedup by using a pointer instead of an
    assigned structure. This seems to help the compiler to optimize
  2. Avoid a conversion error in gzseek when off_t type too small.

    madler committed Feb 5, 2017
    This is a problem in the odd case that the second argument of
    LSEEK is a larger type than off_t. Apparently MinGW defines off_t
    to be 32 bits, but _lseeki64 has a 64-bit second argument.
    Also undo a previous commit to permit MinGW to use _lseeki64.
  3. Fix CLEAR_HASH macro to be usable as a single statement.

    madler committed Jan 23, 2017
    As it is used in deflateParams().
  4. Limit hash table inserts after switch from stored deflate.

    madler committed Jan 21, 2017
    This limits hash table inserts to the available data in the window
    and to the sliding window size in deflate_stored(). The hash table
    inserts are deferred until deflateParams() switches to a non-zero
    compression level.
  5. Permit a deflateParams() parameter change as soon as possible.

    madler committed Jan 16, 2017
    This commit allows a parameter change even if the input data has
    not all been compressed and copied to the application output
    buffer, so long as all of the input data has been compressed to
    the internal pending output buffer. This also allows an immediate
    deflateParams change so long as there have been no deflate calls
    since initialization or reset.
Commits on Jan 16, 2017
Commits on Jan 15, 2017
  1. zlib 1.2.11

    madler committed Jan 15, 2017
  2. Permit immediate deflateParams changes before any deflate input.

    madler committed Jan 15, 2017
    This permits deflateParams to change the strategy and level right
    after deflateInit, without having to wait until a header has been
    written. The parameters can be changed immediately up until the
    first deflate call that consumes any input data.
  3. Update high water mark in deflate_stored.

    madler committed Jan 15, 2017
    This avoids unnecessary filling of bytes in the sliding window
    buffer when switching from level zero to a non-zero level. This
    also provides a consistent indication of deflate having taken
    input for a later commit ...
  4. Fix deflate stored bug when pulling last block from window.

    madler committed Jan 13, 2017
    And some cosmetic cleanups.