Commit Graph

116 Commits

Author SHA1 Message Date
Mark Adler
c376a417a7 Fix deflateEnd() to not report an error at start of raw deflate. 2017-10-12 21:07:22 -07:00
Mark Adler
38e8ce32af Fix CLEAR_HASH macro to be usable as a single statement.
As it is used in deflateParams().
2017-02-15 22:39:26 -08:00
Mark Adler
8ba393e70d Fix bug when window full in deflate_stored(). 2017-02-15 22:39:25 -08:00
Mark Adler
2d80d3f6b5 Limit hash table inserts after switch from stored deflate.
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.
2017-02-15 22:39:25 -08:00
Mark Adler
f9694097dd Permit a deflateParams() parameter change as soon as possible.
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.
2017-02-15 22:38:55 -08:00
Mark Adler
7d60b86782 Change version number to 1.2.11.1. 2017-01-15 22:46:03 -08:00
Mark Adler
cacf7f1d4e zlib 1.2.11 2017-01-15 09:29:40 -08:00
Mark Adler
cbbd20302c Permit immediate deflateParams changes before any deflate input.
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.
2017-01-15 09:29:40 -08:00
Mark Adler
7d9c9d410a Update high water mark in deflate_stored.
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 ...
2017-01-15 09:29:27 -08:00
Mark Adler
4c7c907683 Fix deflate stored bug when pulling last block from window.
And some cosmetic cleanups.
2017-01-15 09:07:14 -08:00
Mark Adler
11ceaed751 Change version number to 1.2.10.1. 2017-01-15 09:07:08 -08:00
Mark Adler
4a090adef8 zlib 1.2.10 2017-01-02 18:21:29 -08:00
Mark Adler
1e3bccd496 Add warnings when compiling with assembler code.
There have been many reports of bugs in the assembler codes
intended to speed up deflate and inflate. They are third-party
contributions in contrib, and so are not supported by the zlib
maintainers.
2017-01-02 17:28:27 -08:00
Mark Adler
bc5503b224 Fix bug in deflate_stored() for zero-length input. 2017-01-02 15:17:59 -08:00
Mark Adler
20e472546e Change version number to zlib 1.2.9.1. 2017-01-01 22:24:17 -08:00
Mark Adler
2fa463bacf zlib 1.2.9 2016-12-31 23:37:10 -08:00
Mark Adler
8f147c3d12 Avoid some random compiler warnings on various platforms. 2016-12-30 23:42:10 -08:00
Mark Adler
ee7d7b5dda Add deflateGetDictionary() function.
Per request, but its utility is likely to be very limited. See the
comments in zlib.h.
2016-12-30 16:29:56 -08:00
Mark Adler
9dc5a8585f Speed up deflation for level 0 (storing).
The previous code slid the window and the hash table and copied
every input byte three times in order to just write the data as
stored blocks with no compression. This commit minimizes sliding
and copying, especially for large input and output buffers.

Level 0 compression is now more than 20 times faster than before
the commit.

Most of the speedup is due to deferring hash table slides until
deflateParams() is called to change the compression level away
from 0. More speedup is due to copying directly from next_in to
next_out when the amounts of available input data and output space
permit it, avoiding the intermediate pending buffer. Additionally,
only the last 32K of the used input data is copied back to the
sliding window when large input buffers are provided.
2016-12-04 07:48:47 -08:00
Mark Adler
7161ad76e2 Assure that deflateParams() will not switch functions mid-block.
This alters the specification in zlib.h, so that deflateParams()
will not change any parameters if there is not enough output space
in the event that a block is emitted in order to allow switching
the compression function.
2016-12-04 07:48:47 -08:00
Mark Adler
9674807c82 Fix bugs in creating a very large gzip header. 2016-12-04 07:39:37 -08:00
Mark Adler
03614c56ad Fix some typos. 2016-10-30 08:49:01 -07:00
Mark Adler
94575859cf Fix bug when level 0 used with Z_HUFFMAN or Z_RLE.
Compression level 0 requests no compression, using only stored
blocks. When Z_HUFFMAN or Z_RLE was used with level 0 (granted,
an odd choice, but permitted), the resulting blocks were mostly
fixed or dynamic. The reason is that deflate_stored() was not
being called in that case. The compressed data was valid, but it
was not what the application requested. This commit assures that
only stored blocks are emitted for compression level 0, regardless
of the strategy selected.
2016-10-27 22:50:43 -07:00
Mark Adler
b516b4bdd7 Do a more thorough check of the state for every stream call.
This verifies that the state has been initialized, that it is the
expected type of state, deflate or inflate, and that at least the
first several bytes of the internal state have not been clobbered.
2016-10-24 21:07:43 -07:00
Mark Adler
049578f0a1 Reject a window size of 256 bytes if not using the zlib wrapper.
There is a bug in deflate for windowBits == 8 (256-byte window).
As a result, zlib silently changes a request for 8 to a request
for 9 (512-byte window), and sets the zlib header accordingly so
that the decompressor knows to use a 512-byte window. However if
deflateInit2() is used for raw deflate or gzip streams, then there
is no indication that the request was not honored, and the
application might assume that it can use a 256-byte window when
decompressing. This commit returns an error if the user requests
a 256-byte window when using raw deflate or gzip encoding.
2016-10-24 15:52:19 -07:00
Mark Adler
da64f1730c Move macro definition in deflate.c to where it is used.
This avoid defining a macro that is never used when not debugging.
2016-10-14 13:18:58 -07:00
Mark Adler
7096424f23 Clean up type conversions. 2016-10-11 22:15:50 -07:00
Mark Adler
3fb251b363 Remove dummy structure declarations for old buggy compilers.
While woolly mammoths still roamed the Earth and before Atlantis
sunk into the ocean, there were C compilers that could not handle
forward structure references, e.g. "struct name;". zlib dutifully
provided a work-around for such compilers. That work-around is no
longer needed, and, per the recommendation of a security audit of
the zlib code by Trail of Bits and TrustInSoft, in support of the
Mozilla Foundation, should be removed since what a compiler will
do with this is technically undefined. From the report: "there is
no telling what interactions the bug could have in the future with
link-time optimizations and type-based alias analyses, both
features that are present (but not default) in clang."
2016-09-21 20:34:04 -07:00
Mark Adler
43bfaba3d7 Align deflateParams() and its documentation in zlib.h.
This updates the documentation to reflect the behavior of
deflateParams() when it is not able to compress all of the input
data provided so far due to insufficient output space.  It also
assures that data provided is compressed before the parameter
changes, even if at the beginning of the stream.
2015-08-02 00:06:28 -07:00
Mark Adler
c901a34c92 Avoid uninitialized access by gzclose_w(). 2015-07-28 23:13:53 -07:00
Mark Adler
51a223def4 Avoid use of DEBUG macro -- change to ZLIB_DEBUG. 2015-07-28 22:44:31 -07:00
Mark Adler
8a979f6c79 Avoid left shift of a negative value in flush rank calculation.
The C standard permits an undefined result for a left shift of a
negative value.
2015-07-05 13:51:50 -07:00
Mark Adler
303d92cfee Spacing cleanup. 2013-05-23 20:11:54 -07:00
Mark Adler
ceeb615f46 Change version number to 1.2.8.1. 2013-05-02 23:12:54 -07:00
Mark Adler
e8fee0ea7b Change version number to 1.2.8. 2013-04-28 15:57:10 -07:00
Mark Adler
388a285cb8 Change version number to 1.2.7.3. 2013-04-13 18:58:46 -07:00
Mark Adler
8a93f49c86 Change version number to 1.2.7.2. 2013-04-13 08:08:57 -07:00
Mark Adler
0b16609409 zlib 1.2.7.1 2013-03-24 22:47:59 -07:00
Mark Adler
c661c374e8 Do not return Z_BUF_ERROR if deflateParam() has nothing to write.
If the compressed data was already at a block boundary, then
deflateParam() would report Z_BUF_ERROR, because there was nothing
to write.  With this patch, Z_OK is returned in that case.
2013-03-24 22:15:04 -07:00
Mark Adler
62d6112a79 Clean up the usage of z_const and respect const usage within zlib.
This patch allows zlib to compile cleanly with the -Wcast-qual gcc
warning enabled, but only if ZLIB_CONST is defined, which adds
const to next_in and msg in z_stream and in the in_func prototype.
A --const option is added to ./configure which adds -DZLIB_CONST
to the compile flags, and adds -Wcast-qual to the compile flags
when ZLIBGCCWARN is set in the environment.
2012-08-13 00:02:40 -07:00
Mark Adler
2689b3cceb Change version number to 1.2.7.1. 2012-05-02 22:38:26 -07:00
Mark Adler
72e2c8f088 Change version number to 1.2.7. 2012-02-12 16:15:47 -08:00
Mark Adler
7b3f71ba5f Change version number to 1.2.6.1. 2012-01-29 21:15:24 -08:00
Mark Adler
0ddfbd2346 Change version number to 1.2.6. 2012-01-16 16:44:29 -08:00
Mark Adler
68f64498c2 Make sure that no extra inserting is done if the strategy changes. 2012-01-14 10:53:23 -08:00
Mark Adler
4f5779a8e7 Insert the first two strings in the hash table after a flush.
This allows deflate to generate the same output when continuing after
a Z_SYNC_FLUSH vs. using deflateSetDictionary() after a Z_FULL_FLUSH
or a deflateReset().  It also slightly improves compression when
flushing by providing two more strings to possibly match at the start
of the new block.
2012-01-13 23:54:40 -06:00
Mark Adler
0b828b4aa6 Write out all of the available bits when using Z_BLOCK.
Previously, the bit buffer would hold 1 to 16 bits after "all" of the
output is provided after a Z_BLOCK deflate() call.  Now at most seven
bits remain in the output buffer after Z_BLOCK.  flush_pending() now
flushes the bit buffer before copying out the byte buffer, in order
for it to really flush as much as possible.
2012-01-07 14:08:02 -08:00
Mark Adler
263b1a05b0 Allow deflatePrime() to insert bits in the middle of a stream.
This allows the insertion of multiple empty static blocks for the
purpose of efficiently bringing a stream to a byte boundary.
2012-01-07 14:03:07 -08:00
Mark Adler
19761b8506 Permit Z_NULL arguments to deflatePending.
This avoids having to create useless variables for return values
that aren't needed.
2011-12-29 00:15:44 -08:00
Mark Adler
9d55abc969 Avoid extraneous empty blocks when doing empty flushes.
Previously when doing an empty flush, a extra static or stored block
could be emitted before the requested empty static or stored block.
This patch prevents the emission of empty blocks by the deflate_*
functions.
2011-12-29 00:03:55 -08:00