Infinite loop on corrupt jpeg
See original GitHub issueIn trying to break PDFBox via embedded corrupt jpegs, I found an infinite loop in twelvemonkeys. Many thanks to Tilman Hausherr for helping me replicate this with the unembedded jpeg and for recommending testing with TwelveMonkeys.
File:
Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG");
ImageReader reader = null;
while (readers.hasNext()) {
reader = readers.next();
break;
}
try (InputStream is = Files.newInputStream(p)) {
ImageInputStream iis = ImageIO.createImageInputStream(is);
reader.setInput(iis);
ImageReadParam irp = reader.getDefaultReadParam();
Raster raster;
try {
BufferedImage image = reader.read(0, irp);
raster = image.getRaster();
} catch (IIOException var20) {
raster = reader.readRaster(0, irp);
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Decoding JPEG puts the process to infinite loop if there is an ...
When you are loading a jpg file with some broken bytes in it, process gets in to infinite loop. Steps to Reproduce. Try...
Read more >jpeg: Avoid an infinite loop with invalid images (!141) · Merge ...
When loading an invalid image with a missing EOI marker we end up triggering an infinite loop inside libjpeg. ... Merge blocked: all...
Read more >PHP :: Bug #34704 :: Infinite recursion due to corrupt JPEG
Bug #34704, Infinite recursion due to corrupt JPEG ... IFD offset" field pointing back to the same structure, creating an infinite loop.
Read more >How to fix corrupt JPEG files - Quora
First Download the Wondershare Repairit application on your system. Hit on "Add Files" to upload the image you want to repair. You can...
Read more >MagickReadImageBlob stuck in endless loop - ImageMagick
The version of IM is 6.8.4-8 (downloaded on April 10th). Basically an encoder passes a JPEG image in memory as a char*. I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let me ignore that test and give it a go!
var5 can == 0, which means nothing is read. read:581, JPEGSegmentImageInputStream$ReplacementSegment (com.twelvemonkeys.imageio.plugins.jpeg) read:426, JPEGSegmentImageInputStream (com.twelvemonkeys.imageio.plugins.jpeg) readInputData:312, JPEGImageReader (com.sun.imageio.plugins.jpeg) readImageHeader:-1, JPEGImageReader (com.sun.imageio.plugins.jpeg) readNativeHeader:731, JPEGImageReader (com.sun.imageio.plugins.jpeg) readHeader:725, JPEGImageReader (com.sun.imageio.plugins.jpeg) readInternal:1130, JPEGImageReader (com.sun.imageio.plugins.jpeg) readRaster:1541, JPEGImageReader (com.sun.imageio.plugins.jpeg) readRaster:1056, JPEGImageReader (com.twelvemonkeys.imageio.plugins.jpeg) main:39, TwelveMonkeysMetadata (org.tallison.pdfbox.images)