Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.0-alpha3
-
None
Description
While trying to use org.apache.commons.imaging.formats.ico.IcoImageParser to read an icon file, I'm getting OutOfMemory Error. The file is corrupted, but that should not lead to an Error.
Icon is downloaded from https://epine.es/assets/icos/epine.ico and hopefully attached to this issue.
Trying to debug the problem, I found out that the cause is in misinterpreting some values in org.apache.commons.imaging.formats.bmp.BmpImageParser#readBmpHeaderInfo(java.io.InputStream, org.apache.commons.imaging.FormatCompliance) method while trying to load data of the single image bitmap in given ico file.
While fileSize value is 5990, the bitmapDataOffset value parsed is 989265922. At the same time expectedDataOffset value is 70, which leads to extraBytes value of 989265852.
Then org.apache.commons.imaging.common.BinaryFunctions#readBytes(java.lang.String, java.io.InputStream, int, java.lang.String) tries to allocate byte array of size 989265852. Which exhausts available memory of the JVM.
Maybe just a simple check of extraBytes > bhi.fileSize could help?
Attachments
Attachments
Issue Links
- links to