Commit Graph

452 Commits

Author SHA1 Message Date
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
Mark Adler
e13def040e Fix compilation with --solo and --debug combined.
However this ends up not really being solo, since it has to
include external libraries.
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
c7d77756d0 Remove files to be installed before copying them in Makefile.in. 2017-01-02 17:04:38 -08:00
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