Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new issue 18 from 201911 #37

Merged
merged 3 commits into from
Nov 8, 2019
Merged

Conversation

aschampion
Copy link
Contributor

The issue was occurring when attempting to flush lz77 (so data was empty), such that the first window was filling the buffer.

Includes a failing test case which passes after the fix. Also includes a deduplicating cleanup of lz77_compress_block -- not knowing anything about lz77, I couldn't diagnose the issue until this refactoring. The refactoring makes it explicit where the first window behavior differs from the normal case, which made it clearer to understand and calls out necessary special behavior (like overlap not getting added to current_block_input_bytes to prevent off-by-one-errors in this particular case, which is different from all the others).

I also confirmed that this fixes my bug in image-rs/image-png#147. I haven't checked @newpavlov's, but since it fixes the reduced case from that created by @lkolbly, it should.

Deduplicate block compression logic by refactoring the first window
behavior from being a separate code block into specific conditionals
where the first window behavior differs.

All tests pass, included ignored.
@oyvindln oyvindln merged commit 317390a into image-rs:dev Nov 8, 2019
@oyvindln
Copy link
Collaborator

oyvindln commented Nov 8, 2019

Awesome, been a bit busy so didn't get around to looking too much into it myself yet. Refactor is probably a good thing.

A bit surprised that it took this long for the bug to appear.

@oyvindln
Copy link
Collaborator

oyvindln commented Nov 8, 2019

Published version with fix to crates.

@aschampion
Copy link
Contributor Author

Thanks for the quick release!

A bit surprised that it took this long for the bug to appear.

As am I -- I've been using the png crate without issue for two years and have put a few hundred TB through it (some of which I'm going back and validating). This has made me a bit nervous, though, so I've set up an AFL fuzz on deflate with long input (since the existing one in png didn't discover this) and will let it run for a few weeks. I will PR that if it finds anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants