image-rs / image-tiff

TIFF decoding and encoding library in pure Rust
MIT License
118 stars 76 forks source link

Decoder regression: mandrill.tiff from upstream #137

Closed RReverser closed 3 years ago

RReverser commented 3 years ago

I've tried to upgrade upstream image crate to tiff 0.7.0, and it uncovered a regression bug: upstream image mandrill.tiff used to decode with 0.6.0, but fails with 0.7.0 with:

Cannot create decoder: FormatError(Format("Neither strips nor tiles were found or both were used in the same file"))

I verified that this problem is reproducible with just image-tiff too, so it's not an issue with integration in the image crate itself. It's also an uncompressed TIFF, so doesn't seem related to my deflate PR (#132) either.

Beyond that, I'm not that familiar with changes between releases, so leaving it up to others to debug this further.

to-mas-kral commented 3 years ago

Sorry, this is the result of some code I added. https://github.com/image-rs/image-tiff/blob/bd1e37d78b731d718200e8909a89e53c93c4df4a/src/decoder/mod.rs#L704-L719

This file has StripOffsets and StripByteCounts, but doesn't have RowsPerStrip, which I didn't expect. Maybe I should just check for (StripOffsets && StripByteCounts) || (TileOffsets && TileByteCounts), otherwise reject the file ?