[Zlib-devel] Silent acceptance of invalid distance codes

Mark Adler madler at alumni.caltech.edu
Fri Sep 17 16:17:31 EDT 2004


On Sep 16, 2004, at 9:25 PM, Cosmin Truta wrote:
> The inflater discards the value of CINFO found in the zlib stream: it
> tests whether CINFO is no bigger than state->wbits (e.g. line 599 in
> zlib-1.2.1.2/inflate.c), but it loses this value afterwards.

Yes, that was intentional.  I wanted inflate to be generous and be able 
to decode whatever the sliding window would permit, regardless of what 
the zlib header said.

> We discovered this problem after we tweaked the CINFO flag incorrectly,
> in libpng. The zlib-based libpng testing program did not tell us that
> something's wrong with the produced PNG images, and we received reports
> about PNGs crashing other apps (presumably, not zlib-based) soon after
> releasing the broken libpng.

I do not want to change the default behavior of inflate in this regard, 
since it's been out so long that something out there will probably 
break if I do.  However I would be willing to add a response to a 
compile-time request, e.g. #define INFLATE_STRICT, to check that.  
Would that be acceptable?

mark





More information about the Zlib-devel mailing list