Repository navigation
Handle TIFF JPEG sampling mismatches safely - #193
Merged
Merged
Conversation
… factors - PluginICO: reject icons whose pixel count exceeds 4096*1024 (~4M pixels) to prevent memory allocation errors caused by abnormally large dimensions. - LibTIFF4/tif_jpeg.c: comment out the JPEG sampling-factor mismatch check in JPEGComputeStrileWidthHeightBytesPerLine(). The strict check caused JPEG-compressed TIFF images with mismatched sampling factors to fail to load; decoding now proceeds instead of returning early. Signed-off-by: haobinnan <[email protected]>
danoli3
force-pushed
the
followup/pr191-safe-tiff-ico
branch
from
October 21, 2026 05:12
91f6e81 to
3ef27bc
Compare
Contributor
|
Once the TIFF issue is resolved, I recommend submitting the fix to the upstream libtiff project and getting it merged. This way, future libtiff updates will include the fix, and we won't need to maintain or reapply a separate patch every time we update the library.@danoli3 |
Decode supported YCbCr sampling mismatches through the full-resolution RGB path, where TIFF raw-plane sizing is not used. Reject unsupported mismatches and add a generated regression fixture that checks decoded pixels against a matching reference. Use division-based ICO pixel-limit validation to prevent signed multiplication overflow, with a header-only crafted ICO regression test. Follow-up to haobinnan's report and compatibility change in PR #191.
danoli3
force-pushed
the
followup/pr191-safe-tiff-ico
branch
from
October 22, 2026 05:04
3ef27bc to
4c7b7cb
Compare
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.
This follow-up preserves the history from PR #191: the first commit is @haobinnan's original change, followed by the safe implementation and regression tests here.
The three TIFF samples shared in #191 all have 2x2 YCbCr subsampling in the TIFF tags but 2x1 factors in the embedded JPEG frame. The loader now handles that supported contiguous YCbCr mismatch through libjpeg's full-resolution RGB path, so raw-plane sizing does not depend on inconsistent factors. Unsupported mismatch types still fail safely. The generated regression test reproduces the same 2x1 JPEG versus 2x2 TIFF mismatch and checks decoded pixels against a matching-metadata reference. It fails with the original strict rejection.
The ICO pixel cap uses division after validating positive dimensions, avoiding signed multiplication overflow. A crafted header-only ICO test checks that dimensions whose product overflows are rejected without allocating image pixels.
Attribution: the original report and proposed compatibility change are by @haobinnan in PR #191. The shared source images were used to confirm the exact sampling-factor discrepancy; they are not included in the repository.
Validation: CMake Debug build with bundled codecs; all 10 CTest tests pass. The updated focused vendor-codec test also passes.