Skip to content

[IMAGING-387] Reject overflowing TIFF strip sizes - #565

Open
dajiaohuang wants to merge 1 commit into
apache:masterfrom
dajiaohuang:IMAGING-387-validate-tiff-strip-size
Open

dajiaohuang wants to merge 1 commit into
apache:masterfrom
dajiaohuang:IMAGING-387-validate-tiff-strip-size

Conversation

@dajiaohuang

Copy link
Copy Markdown

Fixes IMAGING-387.

What

DataReaderStrips.readImageData computes the uncompressed strip byte count as a long, but previously narrowed it to int before decompression. For the issue's 1-bit TIFF dimensions, 28,994,135,625 bytes becomes a negative integer; allocation then fails with NegativeArraySizeException instead of the documented imaging exception.

Validate the long request with Allocator.check before 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

  • DataReaderStripsTest checks that 28,994,135,625 is rejected and that a valid strip size is returned unchanged.
  • Targeted DataReaderStripsTest: 3 tests, 0 failures/errors.
  • Default Maven build (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

  • Read the contribution guidelines.
  • Read the ASF Generative Tooling Guidance.
  • AI use: OpenAI Codex (gpt-6-luna) assisted with source analysis, implementation, and regression tests. Human operator: dajiaohuang.
  • Ran the default Maven build successfully.
  • Added behavioral regression tests.
  • This description explains the issue and change.
  • Commit subject and body identify the issue and summarize the change.

Validate the long strip byte count through Allocator.check before passing it to decompression. Add regressions for oversized and valid strip sizes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant