Repository navigation
[IMAGING-388] Prevent PNG scanline size overflow - #566
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
Calculate scanline byte lengths and sample offsets without int overflow. Reject unrepresentable or out-of-row lengths with ImagingException and add regression coverage.
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-388.
What
PNG scanline sizing used 32-bit multiplication for
bitsPerPixel * widthand rounded the result to bytes with anotherintexpression. For the reported 536,870,921-pixel, 8-bit grayscale row, the product wraps to 72 bits and produces a 9-byte row buffer. Decoding then indexes beyond that buffer.Compute scanline size in
long, reject results that cannot be represented as a Java array length withImagingException, and use long arithmetic for per-sample offsets.BitParsernow reports an out-of-row sample asImagingExceptionrather than leakingArrayIndexOutOfBoundsException.Tests
ImagingException.mvn): BUILD SUCCESS; 1,265 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.