PNG inflate is sometimes missing last byte
kmcallister opened this issue · comments
In some cases inflate.rs
skips the last byte of the decompressed stream, e.g.:
input 02 ec 30 00
flate2 c3
piston
input 02 c8 00 30 00
flate2 30
piston
input f2 84 00 80 00 0b 00 30
flate2 49 49 49 49 49 49 49 50
piston 49 49 49 49 49 49 49
input da 30 7f f1 5d 80 00 ab 00 30
flate2 b0 9f a3 dd 78
piston b0 9f a3 dd
input da ff 80 30 30 82 00 80 00 cb 00 30
flate2 bf e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0
e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0
e0 e0 e0 e0 32 32 32 32 32 32 32 68
piston bf e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0
e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0
e0 e0 e0 e0 32 32 32 32 32 32 32
input f2 00 01 80 00 13 00 30
flate2 48 48 48 48 48 10
piston 48 48 48 48 48
(I found these examples using afl.rs.)
I found some other discrepancies in the inflate implementation that I haven't categorized yet. I might hold off on that, if @nwin's new PNG decoder using libflate2 will be ready soon.
Interesting finding, it’s probably just something off by one… The new PNG decoder should be ready soon. I just need to implement some edge cases and support for 16 bit (which we don’t have right now anyway).
Sounds great! There are some 16-bit images in Servo's test suite.
It’s now passing the whole png testsuite. I need to integrate it into image and we should be ready to roll at least on the png side…