While woolly mammoths still roamed the Earth and before Atlantis
sunk into the ocean, there were C compilers that could not handle
forward structure references, e.g. "struct name;". zlib dutifully
provided a work-around for such compilers. That work-around is no
longer needed, and, per the recommendation of a security audit of
the zlib code by Trail of Bits and TrustInSoft, in support of the
Mozilla Foundation, should be removed since what a compiler will
do with this is technically undefined. From the report: "there is
no telling what interactions the bug could have in the future with
link-time optimizations and type-based alias analyses, both
features that are present (but not default) in clang."
A remarkably creative and diverse set of approaches to letting the
compiler know that opaque was being used when it wasn't is changed
by this commit to the more standard (void)opaque.
This patch allows zlib to compile cleanly with the -Wcast-qual gcc
warning enabled, but only if ZLIB_CONST is defined, which adds
const to next_in and msg in z_stream and in the in_func prototype.
A --const option is added to ./configure which adds -DZLIB_CONST
to the compile flags, and adds -Wcast-qual to the compile flags
when ZLIBGCCWARN is set in the environment.
gzflags() was put in gzwrite.c in order to be compiled exactly the
same as gzprintf(), so that it was guaranteed to return the correct
information. However that causes a static linkage to zlib to bring
in many routines that are often not used. All that is required to
duplicate the compilation environment of gzprintf() is to include
gzguts.h. So that is now done in zutil.c to assure that the correct
flags are returned.
A common request has been the ability to compile zlib to require no
other libraries. This --solo option provides that ability. The price
is that the gz*, compress*, and uncompress functions are eliminated,
and that the user must provide memory allocation and free routines to
deflate and inflate when initializing.
This also moves some of the same from zconf.h to gzguts.h. A new
function, gzflags(), was created to pass the compilation flags
related to vsnprintf usage back to zlibCompileFlags() in zutil.c.
In the process, various compiler configuration files were updated
to include gzflags(), as well as the new gzgetc_() function added
when the gzgetc() macro was introduced in a previous patch.