Commit Graph

6 Commits

Author SHA1 Message Date
christos 3b1253e882 merge conflicts between 1.2.10 and 1.2.13 2022-10-15 19:49:32 +00:00
wiz 0362f707fc zlib: Fix a bug that can crash deflate on some input when using Z_FIXED.
5c44459c3b

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.
2022-03-24 10:13:01 +00:00
christos 6db8c6e988 merge conflicts 2017-01-10 01:27:41 +00:00
christos b85ba082e0 Sprinkle __UNCONST and fix some casts to make this pass WARNS=4
Note, that we cannot fix this properly because it will break the zlib.h API.
2006-01-27 00:45:27 +00:00
christos a1f9f4c090 change DEBUG to ZLIB_DEBUG. 2006-01-16 17:02:29 +00:00
christos aaf4ece63a from www.zlib.net 2006-01-14 20:10:22 +00:00