Repository navigation
Decode TIFF files with large strips and backwards directory chains - #3231
Merged
JimBobSquarePants merged 3 commits intoOct 27, 2026
Merged
Conversation
A missing RowsPerStrip, or one above the image height, is now limited to the height, so planar files without the entry decode and the strip buffer only holds rows that exist. Uncompressed strips, chunky or planar, that are larger than the single buffer allocation limit are read one row at a time. The image dimensions are recorded before the root frame is allocated, so an allocation failure reports the real size, and a frame that fails to decode is released. Directory chains that go backwards in the file are accepted; only a revisited directory is reported as circular.
4 tasks done
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Decode valid TIFF files whose strip sizes exceed the allocator's single-buffer limit or whose directories appear in reverse file order.
The review also corrected incomplete-data handling. Strict and IgnoreAncillary reject short uncompressed data. IgnoreImageData retains available samples and clears missing samples in reused buffers. Reads stay within StripByteCounts. YCbCr size calculations account for subsampling. Planar tile buffers use the depth of each plane.
Tests use stored inputs. There are no runtime TIFF builders or generated image inputs. Independent directory and strip parsing checked the fixture layouts and 16-bit sample bytes. Libtiff also decoded the valid RGB and reversed-directory inputs.
Verification: Release on .NET 10, 897 TIFF and general decoder regression tests passed. This includes 28 strip-layout cases covering all integrity modes. The original PR failed six of the added structural and incomplete-data cases before the review corrections. No existing tolerances or reference images changed.
Fixes #3243