On Tue, 3 Nov 2026 05:09:32 GMT, Jayathirth D V <[email protected]> wrote:

> While reading a TIFF image with LZW compression, we start reading the content 
> of LZW strip data without veryfing whether we actually have the needed bytes. 
> This ends up throwing ArrayIndexOutOfBoundsException, in case of 
> ImageIO.read() we wrap this ArrayIndexOutOfBoundsException into IIOException 
> but if we use the reader directly application will see the AIOOBE.
> 
> TIFF 6.0 mentions that each LZW strip should contain clear & eoi code: 
> https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf#page=61. So the 
> fix now checks these minimal requirements before reading the strip data array.
> 
> TIFF spec doesn't mandate that strip byte count should be positive. So we 
> actually allow 0 strip byte count value and this causes issues in other 
> compression types. Initially i tried restricting the byte count to be 
> positive but these needs more analysis. So i have created 
> [JDK-8396412](https://bugs.openjdk.org/browse/JDK-8396412).
> 
> Testing is green with this update.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 13f1727e
Author:    Jayathirth D V <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/13f1727ee5ef6b1cf12c46228242432c33949b8b
Stats:     90 lines in 2 files changed: 89 ins; 0 del; 1 mod

8394183: TIFF ImageReader throws ArrayIndexOutOfBoundsException for truncated 
LZW strips

Reviewed-by: azvegint, kizune, prr

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

PR: https://git.openjdk.org/jdk/pull/33689

Reply via email to