< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 348,357 **** --- 348,361 ---- } else { int left = blockLength; int off = 0; while (left > 0) { int nbytes = stream.read(block, off, left); + if (nbytes == -1 && left > 0) { + throw new IIOException("Invalid block length for " + + "LZW encoded image data"); + } off += nbytes; left -= nbytes; } nextByte = 0; }
*** 928,937 **** --- 932,945 ---- this.blockLength = stream.readUnsignedByte(); int left = blockLength; int off = 0; while (left > 0) { int nbytes = stream.read(block, off, left); + if (nbytes == -1 && left > 0) { + throw new IIOException("Invalid block length for " + + "LZW encoded image data"); + } left -= nbytes; off += nbytes; } this.bitPos = 0;
< prev index next >