Commit Graph

480 Commits

Author SHA1 Message Date
Mark Adler
e9a52aa129 Check for cc masquerading as gcc or clang in configure. 2022-03-27 13:47:33 -07:00
Mark Adler
1a1e8da703 Remove destructive aspects of make distclean. 2022-03-27 11:01:50 -07:00
Mark Adler
6847291ea0 Separate out address sanitizing from warnings in configure. 2022-03-27 01:54:17 -07:00
Mark Adler
735eaa1ebd Eliminate use of ULL constants.
0xffffffffffffffffULL was causing warnings for C99 usage. The
suffix for the constant is not necessary anyway, so this commit
removes them.
2022-03-27 01:54:17 -07:00
Mark Adler
76f70abbc7 Add fallthrough comments for gcc.
Note intentional switch case fall throughs to avoid gcc warnings.
2022-03-27 01:54:10 -07:00
Mark Adler
2014a993ad Clean up minizip to reduce warnings for testing.
Also fix Makefile test target and permit added compile options.
2022-01-01 14:55:47 -08:00
Mark Adler
58ca4e57ce Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner)
The issue is that unztell64() does not return the correct value if
the position in the current file (in the ZIP archive) is beyond 4
GB. The cause is that unzReadCurrentFile() does not account for
pfile_in_zip_read_info->stream.total_out at line 1854 of unzip.c
wrapping around (it is a 32-bit variable). So, on line 1860
uTotalOutAfter can be *less* than uTotalOutBefore, propagating the
wraparound to uOutThis, which in turn is added to
pfile_in_zip_read_info->total_out_64. That has the effect of
subtracting 4 GB.
2022-01-01 12:09:30 -08:00
Mark Adler
b135d46eaf minizip warning fix if MAXU32 already defined. (gvollant) 2021-12-31 17:22:37 -08:00
Mark Adler
8678871f18 Replace black/white with allow/block. (theresa-m) 2021-12-31 16:57:07 -08:00
Mark Adler
c3f3043f7a Fix indentation in minizip's zip.c. 2021-07-08 09:32:18 -07:00
Mark Adler
0530dbcef9 Improve portability of contrib/minizip. 2021-02-10 15:03:22 -08:00
Mark Adler
506424c640 Correct typo in blast.c. 2021-01-17 21:50:08 -08:00
Mark Adler
53ce271311 Change macro name in inflate.c to avoid collision in VxWorks. 2020-09-17 11:09:46 -07:00
Mark Adler
e54494e6bc Clarify gz* function interfaces, referring to parameter names. 2020-08-31 12:53:58 -07:00
Mark Adler
d71dc66fa8 Fix error in comment on the polynomial representation of a byte. 2019-07-09 08:55:13 -07:00
Mark Adler
0206436615 Fix memory leak on error in gzlog.c.
Thank you Adam Richter.
2019-05-25 22:23:20 -07:00
Mark Adler
79baebe50e Avoid adding empty gzip member after gzflush with Z_FINISH. 2019-04-13 17:08:50 -07:00
Mark Adler
0e96d8e7c7 Explicitly note that the 32-bit check values are 32 bits. 2019-04-05 15:27:47 -07:00
Mark Adler
deb44b5742 Use ARM crc32 instructions if the ARM architecture has them.
The ARM crc32 instructions will be used only if an architecture is
explicitly specified at compile time that has those instructions.
For example, -march=armv8.1-a or -march=armv8-a+crc, or if the
machine being compiled on has the instructions, -march=native.
2019-02-17 20:49:29 -08:00
Mark Adler
52fc78baf2 Add use of the ARMv8 crc32 instructions when requested.
Define the macro Z_ARM_CRC32 at compile time to use the ARMv8
(aarch64) crc32x and crc32b instructions. This code does not check
for the presence of the crc32 instructions. Those instructions are
optional for ARMv8.0, though mandatory for ARMv8.1 and later. The
use of the crc32 instructions is about ten times as fast as the
software braided calculation of the CRC-32. This can noticeably
speed up the decompression of gzip streams.
2019-02-17 19:48:57 -08:00
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