[
https://issues.apache.org/jira/browse/IMAGING-373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17822423#comment-17822423
]
Milan Nikl commented on IMAGING-373:
------------------------------------
I'm using the library to load selected types of images (GIF, ICO) inside a
flink pipeline within a taskmanager with JVM Heap Size: 564 MB. That's why I
was getting OOM.
I tried using the imaging jar from master branch [commit
6519bad|https://github.com/apache/commons-imaging/commit/6519bad07f5ebcdfa0e10830c3e57064619a2cb7]
and after 24h +/- in the testing environment, there hasn't been any unexpected
exception so far.
> OutOfMemory with invalid ICO input file
> ---------------------------------------
>
> Key: IMAGING-373
> URL: https://issues.apache.org/jira/browse/IMAGING-373
> Project: Commons Imaging
> Issue Type: Bug
> Components: Format: BMP, Format: ICO
> Affects Versions: 1.0-alpha3
> Reporter: Milan Nikl
> Priority: Major
> Fix For: 1.0-M1
>
> Attachments: epine.ico
>
>
> 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.
> [^epine.ico]
>
> 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?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)