Piotr Karwasz created IMAGING-399:
-------------------------------------

             Summary: PNG iCCP chunk is inflated without limit instead of to 
the profile size declared in its header
                 Key: IMAGING-399
                 URL: https://issues.apache.org/jira/browse/IMAGING-399
             Project: Commons Imaging
          Issue Type: Bug
          Components: Format: PNG
    Affects Versions: 1.0.0-alpha6
            Reporter: Piotr Karwasz


{{PngChunkIccp}} inflates the embedded ICC profile with 
{{IOUtils.toByteArray(new InflaterInputStream(...))}}, which keeps reading 
until the compressed data ends. A small iCCP chunk can therefore inflate to 
hundreds of megabytes, up to about 1000 times its size, even though an ICC 
profile declares its own size in the first 4 bytes of its header and 
{{ICC_Profile.getInstance}} ignores any data past that size.

Suggested fix: inflate the 132-byte ICC header first, check the declared size 
against the {{Allocator}} limit, then read exactly that many bytes 
incrementally with {{IOUtils.toByteArray(InputStream, int, int)}}, throwing an 
{{ImagingException}} if the profile is shorter than declared. A pull request 
with the fix and tests follows.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to