In https://bugs.openjdk.org/browse/JDK-8270915 we have a valid GIF image which 
was generated using a third party app, but it contains large amount of 
Metadata(numerous Application extension blocks).

Also GIFImageReader doesn't use ignoreMetadata flag set by user while reading 
Metadata which causes heavy memory usage in this scenario. We need to provide 
support for ignoring metadata in GIFImageReader, so readMetadata() is updated 
to use the "ignoreMetadata" flag and ignore all blocks except "Image 
Descriptor" and "Graphics Control Extension".

I have updated readMedata() to also use ReaderUtil.staggeredReadByteStream() 
where we are allocating upfront memory based on parameters from metadata. Also 
this PR has small refactoring of import statements.

To replicate the bug we need byte stream with large amount of valid metadata, 
so i am not able to add regression test case.

-------------

Commit messages:
 - Fix indentation
 - Use Staggered read instead of readFully in readMetadata()
 - Fix extra blocksize logic
 - Update concatenateBlocks logic
 - Initial working change

Changes: https://git.openjdk.org/jdk/pull/10536/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10536&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8270915
  Stats: 88 lines in 1 file changed: 39 ins; 10 del; 39 mod
  Patch: https://git.openjdk.org/jdk/pull/10536.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10536/head:pull/10536

PR: https://git.openjdk.org/jdk/pull/10536

Reply via email to