image-rs / deflate-rs

An implementation of a DEFLATE encoder in rust
Apache License 2.0
53 stars 14 forks source link

Fix roundtrip bug #41

Closed aschampion closed 4 years ago

aschampion commented 4 years ago

This should be looked at by someone who understands the algorithm. I looked at which paths of process_chunk_lazy these inputs went through versus which paths they went through with a byte chopped off the end of the buffer (when there was no bug), and noticed that the failing cases exited in this macro call. This led me to suspect it was a wrong return value; removing the +1 offset fixed it. I was just a monkey with a hammer here.

There are ~50 failing cases now from the AFL fuzz, so tomorrow when I have access to box running the fuzz I'll see if this fixes those.

Closes #39.

After this is merged I'll update #40 so that AFL and the regression tests can share the same seed files, then mark that PR as ready.

oyvindln commented 4 years ago

Ah, thanks for the work, I haven't gotten around to investigating this.

Will have to check if the write_literal! call below needs to be altered as well. I'll wait with merging until you've tested.

aschampion commented 4 years ago

This fixed all but three of the crashes fuzzing found so far. Will open the remaining failures as a new issue for tracking.