Frommi / miniz_oxide

Rust replacement for miniz
MIT License
174 stars 49 forks source link

Add testcase for case where both input and output buffers are full. #68

Closed golddranks closed 4 years ago

golddranks commented 4 years ago

This commit adds a testcase that fails because of an apparent bug in miniz_oxide. The bug happens when it just so happens that both input buffer becomes empty and output buffer becomes full during the same call to the inflate::core::decompress function. In that case, I think that most users of the library expect to get HasMoreOutput status, urging them to read the output value before it gets overwritten by another decompress call.

However, in some (but only in some) cases, NeedsMoreInput status is returned. If the user naively pattern-matches to the status and calls again with more input, data loss occurs. Therefore, when the output buffer is full, HasMoreOutput should always be prioritized over NeedsMoreInput.

I don't still know enough about the insides of this library to suggest a fix in the same PR. However, at least I was able to reduce the bug into a relatively simple case.

oyvindln commented 4 years ago

Thanks, will have to look into this.