Commit Graph

457 Commits

Author SHA1 Message Date
Mark Adler 0b5c158cc7 Fix bug in gzwrite.c that produced corrupt gzip files. 2017-01-02 16:17:43 -08:00
Mark Adler bc5503b224 Fix bug in deflate_stored() for zero-length input. 2017-01-02 15:17:59 -08:00
Mark Adler 52aa5501ec Minor edits and clarifications of comments. 2017-01-01 22:24:37 -08:00
Mark Adler 7358ef23c2 Avoid warnings on snprintf() return value. 2017-01-01 22:24:37 -08:00
Mark Adler 20e472546e Change version number to zlib 1.2.9.1. 2017-01-01 22:24:17 -08:00
Mark Adler 6bdca5060d Fix some stray 1.2.8.1 version numbers. 2017-01-01 22:23:41 -08:00
Mark Adler 2fa463bacf zlib 1.2.9 2016-12-31 23:37:10 -08:00
Mark Adler 14e3194e1e Update Visual Studio project files (AraHaan). 2016-12-31 18:57:48 -08:00
Mark Adler b9ae6f0079 Add crc32_z() and adler32_z() functions with size_t lengths. 2016-12-31 17:50:52 -08:00
Mark Adler 61b91f27f8 Make z_size_t unsigned long for non-standard C.
Also declare z_size_t when compiling solo.
2016-12-31 17:50:39 -08:00
Mark Adler cca27e95cf Avoid the need for ssize_t.
Limit read() and write() requests to sizes that fit in an int.
This allows storing the return value in an int, and avoiding the
need to use or construct an ssize_t type. This is required for
Microsoft C, whose _read and _write functions take an unsigned
request and return an int.
2016-12-31 10:06:40 -08:00
Mark Adler b7fbee2156 Use a uniform approach for the largest value of an unsigned type. 2016-12-31 08:49:17 -08:00
Mark Adler f3fcb92cf6 Use intptr_t for z_ssize_t on MSVC. 2016-12-30 23:42:22 -08:00
Mark Adler 8f147c3d12 Avoid some random compiler warnings on various platforms. 2016-12-30 23:42:10 -08:00
Mark Adler fb26fc427f Allow minigzip to compile when testing with ./configure --solo. 2016-12-30 22:04:22 -08:00
Mark Adler d46546544a Replace as400 with os400 for OS/400 support (Monnerat). 2016-12-30 20:00:57 -08:00
Mark Adler f12d3dc367 Detect clang in cc version. 2016-12-30 20:00:57 -08:00
Mark Adler 50dca6d127 Fix init macros to use z_ prefix when requested. 2016-12-30 20:00:56 -08:00
Mark Adler d6f0da2fa3 Fix character encoding and link in contrib README. 2016-12-30 20:00:51 -08:00
Mark Adler 79b5c5acf0 Use snprintf() for later versions of Microsoft C. 2016-12-30 17:13:31 -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 feafcfaa05 No need to check for NULL argument to free(). 2016-12-30 14:30:52 -08:00
Mark Adler 77bc4f8944 Add gzfwrite(), duplicating the interface of fwrite(). 2016-12-04 18:47:34 -08:00
Mark Adler 44dfd831d2 Add gzfread(), duplicating the interface of fread(). 2016-12-04 18:35:41 -08:00
Mark Adler 3f8c768745 Fix compile option for when z_size_t needs to be a long long. 2016-12-04 17:19:36 -08:00
Mark Adler ca50ebd4df Create z_size_t and z_ssize_t types.
Normally these are set to size_t and ssize_t. But if they do not
exist, then they are set to the smallest integer type that can
contain a pointer. size_t is unsigned and ssize_t is signed.
2016-12-04 07:48:48 -08:00
Mark Adler c5ee34c28a Don't need to emit an empty fixed block when changing parameters.
gzsetparams() was using Z_PARTIAL_FLUSH when it could use Z_BLOCK
instead. This commit uses Z_BLOCK, which avoids emitting an
unnecessary ten bits into the stream.
2016-12-04 07:48:47 -08:00
Mark Adler 123f9cfaf7 Clean up gz* function return values.
In some cases the return values did not match the documentation,
or the documentation did not document all of the return values.
gzprintf() now consistently returns negative values on error,
which matches the behavior of the stdio fprintf() function.
2016-12-04 07:48:47 -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 1101ea79c6 Explicitly ignore a return value in gzwrite.c. 2016-12-04 07:48:47 -08:00
Mark Adler 21c66cd5ac Increase verbosity required to warn about bit length overflow.
When debugging the Huffman coding would warn about resulting codes
greater than 15 bits in length. This is handled properly, and is
not uncommon. This increases the verbosity of the warning by one,
so that it is not displayed by default.
2016-12-04 07:48:47 -08:00
Mark Adler 37281ac222 Add uncompress2() function, which returns the input size used. 2016-12-04 07:48:47 -08:00
Mark Adler 001300d0d9 Minor edits to the documentation in source file contents. 2016-12-04 07:48:41 -08:00
Mark Adler 9674807c82 Fix bugs in creating a very large gzip header. 2016-12-04 07:39:37 -08:00
Mark Adler fc130cdd9f Add --debug (-d) option to ./configure to define ZLIB_DEBUG. 2016-12-04 07:39:37 -08:00
Mark Adler a456d898bb Use memcpy for stored blocks.
This speeds up level 0 by about a factor of three, as compared to
the previous byte-at-a-time loop. We can do much better though. A
later commit avoids this copy for level 0 with large buffers,
instead copying directly from the input to the output. This commit
still speeds up storing incompressible data found when compressing
normally.
2016-12-04 07:39:25 -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 bedea2483b Clean up and comment the use of local for static. 2016-10-26 10:25:10 -07:00
Mark Adler ce12c5cd00 Make a noble effort at setting OS_CODE correctly.
This updates the OS_CODE determination at compile time to match as
closely as possible the operating system mappings documented in
the PKWare APPNOTE.TXT version 6.3.4, section 4.4.2.2. That byte
in the gzip header is used by nobody for anything, as far as I can
tell. However we might as well try to set it appropriately.
2016-10-25 20:45:41 -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 77fd7e56bf Document the rejection of 256-byte window requests in zlib.h. 2016-10-24 16:00:51 -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 a0bf0f31d3 Avoid obfuscating use of default case in inftrees.c. 2016-10-14 13:30:18 -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 ebbc57393d Avoid recursive gzgetc() macro call.
Recursive macro calls are normally caught by the preprocessor and
avoided. This commit avoids the possibility of a problem entirely.
2016-10-14 13:16:07 -07:00
Mark Adler 7d6956b6a1 Make globals in examples local to compilation unit. 2016-10-14 13:10:54 -07:00
Mark Adler 8b95fa19cd Add --warn option to ./configure, instead of environment variable. 2016-10-11 22:21:04 -07:00
Mark Adler 7096424f23 Clean up type conversions. 2016-10-11 22:15:50 -07:00