-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b01
-
x86_64
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8214644 | 8u211 | Fairoz Matte | P4 | Resolved | Fixed | b01 |
JDK-8220990 | emb-8u211 | Fairoz Matte | P4 | Resolved | Fixed | master |
FULL PRODUCT VERSION :
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When loading a BMP image using indexed color model (palette), an java.lang.IndexOutOfBoundsException occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a 8BPP indexed color BMP (I have used GIMP for windows)
Try to load it using ImageIO.read method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
a BufferedImage with the BMP content
ACTUAL -
A nice java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len > b.length!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len > b.length!
at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:346)
at com.sun.imageio.plugins.bmp.BMPImageReader.read8Bit(BMPImageReader.java:1160)
at com.sun.imageio.plugins.bmp.BMPImageReader.read(BMPImageReader.java:923)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
...
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
ImageInputStream is = new FileImageInputStream(new File("indexed.bmp"));
BufferedImage img = ImageIO.read(is);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
The bug is in BMPImageReader.read(int imageIndex, ImageReadParam param) method, at line 918.
A "break" is missing in the switch case VERSION_4_4_BIT, the reader also execute the next case (VERSION_4_8_BIT) that cause the IndexOutOfBoundsException.
I have tested with a copy of this class, by adding a break at line 918 and it fixes the problem.
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When loading a BMP image using indexed color model (palette), an java.lang.IndexOutOfBoundsException occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a 8BPP indexed color BMP (I have used GIMP for windows)
Try to load it using ImageIO.read method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
a BufferedImage with the BMP content
ACTUAL -
A nice java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len > b.length!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len > b.length!
at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:346)
at com.sun.imageio.plugins.bmp.BMPImageReader.read8Bit(BMPImageReader.java:1160)
at com.sun.imageio.plugins.bmp.BMPImageReader.read(BMPImageReader.java:923)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
...
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
ImageInputStream is = new FileImageInputStream(new File("indexed.bmp"));
BufferedImage img = ImageIO.read(is);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
The bug is in BMPImageReader.read(int imageIndex, ImageReadParam param) method, at line 918.
A "break" is missing in the switch case VERSION_4_4_BIT, the reader also execute the next case (VERSION_4_8_BIT) that cause the IndexOutOfBoundsException.
I have tested with a copy of this class, by adding a break at line 918 and it fixes the problem.
- backported by
-
JDK-8214644 IndexOutOfBoundsException when reading indexed color BMP
-
- Resolved
-
-
JDK-8220990 IndexOutOfBoundsException when reading indexed color BMP
-
- Resolved
-
- relates to
-
JDK-8033716 Fix raw and unchecked lint warnings in com.sun.imageio
-
- Resolved
-
-
JDK-8212914 Test javax/imageio/plugins/bmp/BMP8BPPLoadTest.java fails
-
- Resolved
-