Skip to content

fix issue with newer versions of zlib

Martin Petráček requested to merge newer-zlib-fix into master

This fixes #53 (closed), ucollect should now work with newer version of zlib.

The reason why it wasn't working is that the zstream structure was first initialized by (in|de)flateInit and then copied to struct uplink.

This approach is no longer working with newer versions of zlib (>1.2.8, which is in Ubuntu 14.04).

(in|de)flateInit in newer versions of zlib (>=1.2.9) also saves pointer to itself (zstream->state->strm)[1], which is then checked in each invocation of (in|de)flate[2] by (in|de)flateCheckState[3] and has to match the passed parameter.

As a result, if zstream was first initialized and then copied, (in|de)flateCheckState failed, which consequently made the whole (in|de)flate function fail (returning Z_STREAM_ERROR).

I don't understand WHY they decided to start to do this checking now though.

This change removes the local initialization of zstream and then copying it to struct uplink. Instead, the initialization is done directly on struct uplink's zstream.

Tested as working with zlib-1.2.11, please test it on currently used versions. The change is quite small, I suppose it shouldn't break anything.

[1] https://github.com/madler/zlib/blob/v1.2.9/inflate.c#L228

[2] https://github.com/madler/zlib/blob/v1.2.9/inflate.c#L645

[3] https://github.com/madler/zlib/blob/v1.2.9/inflate.c#L112

Merge request reports