Piotr Karwasz created IMAGING-400:
-------------------------------------

             Summary: PNG zTXt and iTXt chunks are inflated without limit
                 Key: IMAGING-400
                 URL: https://issues.apache.org/jira/browse/IMAGING-400
             Project: Commons Imaging
          Issue Type: Bug
          Components: Format: PNG
    Affects Versions: 1.0.0-alpha6
            Reporter: Piotr Karwasz


{{PngChunkZtxt}} and {{PngChunkItxt}} inflate their compressed text with 
{{IOUtils.toByteArray(new InflaterInputStream(...))}}, which keeps reading 
until the compressed data ends, regardless of the {{Allocator}} limit that 
bounds other allocations. Since Deflate reaches ratios of about 1000:1, a small 
text chunk can inflate to gigabytes when reading metadata with 
{{Imaging.getMetadata}}, {{getImageInfo}} or {{getXmpXml}}.

Suggested fix: inflate through a {{BoundedInputStream}} that throws an 
{{AllocationRequestException}} once the inflated text exceeds the {{Allocator}} 
limit, and decode it with {{IOUtils.toString}}. This needs a public 
{{Allocator.getLimit()}}. A pull request with the fix and tests follows.



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

Reply via email to