trifectatechfoundation / zlib-rs

A safer zlib
zlib License
148 stars 15 forks source link

`flush` is not respected in `inflate()` #114

Closed cjgriscom closed 5 months ago

cjgriscom commented 5 months ago

The state handler in the original inflate.c references the flush parameter to inflate() where it modifies the exit behavior based on this condition:

case TYPE:
    if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
    /* fallthrough */
case TYPEDO:

Now, this case is already correctly implemented in zlib-rs, but since the state handler has been moved out of inflate(), it must reference state.flush, which is never assigned.

I made a PR to address this and get FLUSH_BLOCK working properly. https://github.com/memorysafety/zlib-rs/pull/113