Repository navigation
[IMAGING-387] Reject overflowing TIFF strip sizes - #565
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
Validate the long strip byte count through Allocator.check before passing it to decompression. Add regressions for oversized and valid strip sizes.
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.
Fixes IMAGING-387.
What
DataReaderStrips.readImageDatacomputes the uncompressed strip byte count as along, but previously narrowed it tointbefore decompression. For the issue's 1-bit TIFF dimensions, 28,994,135,625 bytes becomes a negative integer; allocation then fails withNegativeArraySizeExceptioninstead of the documented imaging exception.Validate the long request with
Allocator.checkbefore narrowing, then pass that checked size to decompression. Apply the same checked size to planar strip allocation. This rejects requests beyond the allocator's supported limit before any int truncation.Tests
DataReaderStripsTestchecks that 28,994,135,625 is rejected and that a valid strip size is returned unchanged.DataReaderStripsTest: 3 tests, 0 failures/errors.mvn): BUILD SUCCESS; 1,261 tests, 0 failures, 0 errors, 7 skipped. The task-local checkout was normalized to the repository's LF source convention for Checkstyle.Contribution checklist
dajiaohuang.