[jdk21u-dev] RFR: 8351110: ImageIO.write for JPEG can write corrupt JPEG for certain thumbnail dimensions

Roland Mesde duke at openjdk.org
Thu Nov 13 23:37:41 UTC 2025


Backporting JDK-8351110: ImageIO.write for JPEG can write corrupt JPEG for certain thumbnail dimensions. JPEG segments have a 65535-byte limit, but the code was writing larger segments, causing parsing errors when reading files back.

Two fixes implemented:

1. Constrains thumbnail dimensions to fit within the segment limit.

2. Added safety check to write2bytes that throws IIOException if segment size is exceeded.

Ran GHA Sanity Checks (passed) and related test (passed).

-------------

Commit messages:
 - Backport 60f3d607412dfe289f33dd922dfc1c9ff766810f

Changes: https://git.openjdk.org/jdk21u-dev/pull/2471/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=2471&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8351110
  Stats: 168 lines in 3 files changed: 167 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk21u-dev/pull/2471.diff
  Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/2471/head:pull/2471

PR: https://git.openjdk.org/jdk21u-dev/pull/2471


More information about the jdk-updates-dev mailing list