Commit Graph

510 Commits

Author SHA1 Message Date
Mark Adler
aec89faa2e Correct comment in crc32.c. 2019-02-03 19:54:46 -08:00
Mark Adler
0d36ec47f3 Don't bother computing check value after successful inflateSync().
inflateSync() is used to skip invalid deflate data, which means
that the check value that was being computed is no longer useful.
This commit turns off the check value computation, and furthermore
allows a successful return if the compressed data terminated in a
graceful manner. This commit also fixes a bug in the case that
inflateSync() is used before a header is ever processed. In that
case, there is no knowledge of a trailer, so the remainder is
treated as raw.
2019-01-02 20:40:40 -08:00
Mark Adler
7c0c75e990 Use atomic test and set, if available, for dynamic CRC tables. 2018-12-26 13:50:27 -08:00
Mark Adler
f8719f5ae5 Speed up software CRC-32 computation by a factor of 1.5 to 3.
Use the interleaved method of Kadatch and Jenkins in order to make
use of pipelined instructions through multiple ALUs in a single
core. This also speeds up and simplifies the combination of CRCs,
and updates the functions to pre-calculate and use an operator for
CRC combination.
2018-12-26 12:26:52 -08:00
Mark Adler
41d86c73b2 Add crc32_combine_gen() and crc32_combine_op() for fast combines.
When the same len2 is used repeatedly, it is faster to use
crc32_combine_gen() to generate an operator, that is then used to
combine CRCs with crc32_combine_op().
2018-11-04 10:31:46 -08:00
Mark Adler
47cb412957 Add tables for crc32_combine(), to speed it up by a factor of 200. 2018-11-03 19:45:22 -07:00
Mark Adler
921d81b2a8 Fix the zran.c example to work on a multiple-member gzip file. 2018-10-14 09:57:34 -07:00
Mark Adler
354fa43d12 Add gznorm.c example, which normalizes gzip files. 2018-10-07 13:55:00 -07:00
Mark Adler
cd16ff0b3a Show all the codes for the maximum tables size in enough.c. 2018-08-05 23:08:33 -07:00
Mark Adler
d00c147f53 Clarify that prefix codes are counted in enough.c.
There is no assurance that all prefix codes are reachable as
optimal Huffman codes for the numbers of symbols encountered in
a deflate block. This code considers all possible prefix codes,
which might be a larger set than all possible Huffman codes,
depending on the constraints.
2018-08-05 23:08:25 -07:00
Mark Adler
5b1381006b Use inline function instead of macro for index in enough.c. 2018-08-05 23:08:13 -07:00
Mark Adler
8ba2cdb6bd Clean up code style in enough.c, update version. 2018-08-01 19:51:56 -07:00
Mark Adler
4c14b51587 Use a macro for the printf format of big_t in enough.c. 2018-08-01 01:39:47 -07:00
Mark Adler
194e558efe Use a structure to make globals in enough.c evident. 2018-08-01 01:37:03 -07:00
Mark Adler
4346a16853 Assure that the number of bits for deflatePrime() is valid. 2018-04-19 19:47:53 -07:00
Mark Adler
5c44459c3b Fix a bug that can crash deflate on some input when using Z_FIXED.
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 1.2.2.2, 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.
2018-04-19 19:47:11 -07:00
Mark Adler
e99813dbfe Correct the initialization requirements for deflateInit2(). 2018-01-31 13:24:12 -08:00
Mark Adler
bf88202e31 Emphasize the need to continue decompressing gzip members. 2018-01-08 18:16:05 -08:00
Mark Adler
ba9df2111e Add legal disclaimer to README. 2017-10-12 21:57:51 -07:00
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
288f108031 Remove old assembler code in which bugs have manifested.
In addition, there is not sufficient gain from the inflate
assembler code to warrant its inclusion.
2017-10-12 20:27:14 -07:00
Mark Adler
a577351394 Make the names in functions declarations identical to definitions. 2017-10-12 20:03:51 -07:00
Mark Adler
723e928b84 Avoid an undefined behavior of memcpy() in _tr_stored_block().
Allegedly the behavior of memcpy() is undefined if the source
pointer is NULL, even if the number of bytes to copy is zero.
2017-10-12 19:44:01 -07:00
Mark Adler
b25d5fcdcf Avoid undefined behaviors of memcpy() in gz*printf(). 2017-10-12 19:35:59 -07:00
Mark Adler
ae49d1472e Avoid an undefined behavior of memcpy() in gzappend(). 2017-10-12 19:27:59 -07:00
Mark Adler
3c46f5ddb5 Avoid the use of ptrdiff_t.
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.
2017-06-03 09:53:33 -07:00
Mark Adler
44e8ac810d Handle case where inflateSync used when header never processed.
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.
2017-04-16 08:35:33 -07:00
Mark Adler
89245c0a84 Don't compute check value for raw inflate if asked to validate. 2017-03-30 14:48:43 -07:00
Mark Adler
be5e3647c4 Add address checking in clang to -w option of configure. 2017-02-18 23:07:01 -08:00
Mark Adler
90287635ef Return an error if the gzputs string length can't fit in an int. 2017-02-15 22:39:26 -08:00
Mark Adler
60a5ecc62b Small speedup to inflate [psumbera].
Seeing a few percent speedup by using a pointer instead of an
assigned structure. This seems to help the compiler to optimize
better.
2017-02-15 22:39:26 -08:00
Mark Adler
e1f1a3a146 Update use of errno for newer Windows CE versions. 2017-02-15 22:39:26 -08:00
Mark Adler
793ad7f559 Avoid some conversion warnings in gzread.c and gzwrite.c. 2017-02-15 22:39:26 -08:00
Mark Adler
e00a2bd392 Have Makefile return non-zero error code on test failure. 2017-02-15 22:39:26 -08:00
Mark Adler
a362293745 Avoid a conversion error in gzseek when off_t type too small.
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.
2017-02-15 22:39:26 -08: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
5ff989033e Cygwin does not have _wopen(), so do not create gzopen_w() there. 2017-01-16 09:38:36 -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
37ed2112a1 Update vestigial comment from very old Info-ZIP deflate. 2017-01-15 09:07:14 -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
74d2696d87 Update location of Visual Studio project files. 2017-01-15 09:07:14 -08:00
Mark Adler
c38a2603ce Delete user-specific Visual Studio project files. 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