w3c / epubcheck

The conformance checker for EPUB publications
https://www.w3.org/publishing/epubcheck/
BSD 3-Clause "New" or "Revised" License
1.66k stars 403 forks source link

java.lang.ArrayIndexOutOfBoundsException: 4096 #756

Open marbetschar opened 7 years ago

marbetschar commented 7 years ago

I'm getting the following error during ePub validation (using v4.0.2):

$: java -jar epubcheck.jar Selbststandig\ machen\ -\ sevDesk\ Lexikon.epub
Verwendung der EPUB 2.0.1 Prüfungen
java.lang.ArrayIndexOutOfBoundsException: 4096
    at com.sun.imageio.plugins.gif.GIFImageReader.read(GIFImageReader.java:984)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1308)
    at com.adobe.epubcheck.bitmap.BitmapChecker.getImageSizes(BitmapChecker.java:145)
    at com.adobe.epubcheck.bitmap.BitmapChecker.checkImageDimensions(BitmapChecker.java:269)
    at com.adobe.epubcheck.bitmap.BitmapChecker.runChecks(BitmapChecker.java:321)
    at com.adobe.epubcheck.opf.OPFChecker.checkItemContent(OPFChecker.java:423)
    at com.adobe.epubcheck.opf.OPFChecker.runChecks(OPFChecker.java:157)
    at com.adobe.epubcheck.ocf.OCFChecker.runChecks(OCFChecker.java:300)
    at com.adobe.epubcheck.api.EpubCheck.doValidate(EpubCheck.java:215)
    at com.adobe.epubcheck.tool.EpubChecker.validateFile(EpubChecker.java:161)
    at com.adobe.epubcheck.tool.EpubChecker.processFile(EpubChecker.java:495)
    at com.adobe.epubcheck.tool.EpubChecker.run(EpubChecker.java:255)
    at com.adobe.epubcheck.tool.Checker.main(Checker.java:31)
EpubCheck abgeschlossen
tofi86 commented 7 years ago

This seems to happen when checking GIF files. Can you narrow down the problem to a single GIF image and attach this file or a demo epub file containing this GIF?

tofi86 commented 7 years ago

Still waiting for feedback...

Can you narrow down the problem to a single GIF image and attach this file or a demo epub file containing this GIF?

minhductin2 commented 7 years ago

Hi tofi86,

You can check attachment file which also produces the same error. o23l9

tofi86 commented 7 years ago

Thanks for the demo data, we'll take a look!

marbetschar commented 7 years ago

@tofi86 sorry for being unresponsive - I was not able to reproduce the issue. @minhductin2 thanks for the demo data!

tofi86 commented 7 years ago

I can confirm that the error can be reproduced with the above animated GIF.

However, when reading this StackOverflow question I have the impression that there isn't an easy patch for this besides switching the ImageIO GIFImageReader.

rdeltour commented 5 years ago

I could reproduce with the animated GIF as well.

This is caused by a known bug in OpenJDF, see JDK-7132728.

There is an issue open to the TwelveMonkeys ImageIO plugins (which we use in EPUBCheck) to add support for GIFs, with explicit mention of this issue, see haraldk/TwelveMonkeys#316. Let's keep track of the issue there! By the way, the issue is marked as sponsor needed, so if anyone wants to accelerate the resolution, maybe it's a good idea to get in touch with the TwelveMonkeys folks 🙂

I will push a patch to make sure that the ArrayIndexOutOfBoundsException is caught, so that it's "only" reported as an image corruption issue and the processing at least continues with other checks.

In the mid term, we could also possibly make a special case for *.gif files in the catch block, to allow them anyway and ignore the exception; although i'm a little concerned about any false-negatives it might cause. Thoughts?

rdeltour commented 5 years ago

I pushed a repro to the branch fix/issue-756/gifs.