Skip to content

IMAGING-396: Throw ImagingException for malformed WBMP, sCAL, XPM and IPTC input - #579

Open
Marti2203 wants to merge 1 commit into
apache:masterfrom
Marti2203:malformed-input
Open

Marti2203 wants to merge 1 commit into
apache:masterfrom
Marti2203:malformed-input

Conversation

@Marti2203

Copy link
Copy Markdown

Fixes IMAGING-396.

Malformed input made four parsers throw unchecked exceptions instead of ImagingException:

  • WBMP: rowLength * height overflowed int (IllegalArgumentException). The size is now computed in long and rejected above Integer.MAX_VALUE.
  • PNG: an empty sCAL chunk (ArrayIndexOutOfBoundsException). It is now rejected.
  • XPM: end of input where a string is expected (NullPointerException). The token is now checked for null.
  • IPTC: a block ending inside a record header (ArrayIndexOutOfBoundsException). Reading stops there, as it already does for an unexpected tag marker.

The new MalformedInputTest (4 tests, small base64 inputs) fails 4/4 without the change and passes with it. mvn -B verify checkstyle:check pmd:check passes (1263 tests, 0 failures).

This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually. The patch and this description were prepared with AI assistance (Claude Code) and reviewed by me; the commit carries an Assisted-By: trailer.

… IPTC input

Malformed input made several parsers throw unchecked exceptions instead
of ImagingException: a WBMP size whose row length times height overflows
int (IllegalArgumentException), an empty PNG sCAL chunk
(ArrayIndexOutOfBoundsException), an XPM file ending where a string is
expected (NullPointerException), and an IPTC block ending inside a record
header (ArrayIndexOutOfBoundsException). Compute the WBMP size in long and
reject sizes above Integer.MAX_VALUE, reject an empty sCAL chunk, check
the XPM token for null, and stop reading IPTC records when the record
header does not fit, as for an unexpected tag marker.

Assisted-By: Claude Code:claude-opus-5-5
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