author | jdv |
Wed, 10 Jan 2018 12:45:14 +0530 | |
changeset 48643 | 2ea3667af41d |
permissions | -rw-r--r-- |
48643
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
1 |
/* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
4 |
* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
8 |
* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
13 |
* accompanied this code). |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
14 |
* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
18 |
* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
21 |
* questions. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
22 |
*/ |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
23 |
|
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
24 |
/* |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
25 |
* @test |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
26 |
* @bug 8191073 |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
27 |
* @summary Test verifies that when user tries to read image data from a |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
28 |
* tables-only image input stream it should through IIOException |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
29 |
* instead of throwing any other exception as per specification. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
30 |
* @run main JpegTablesOnlyReadTest |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
31 |
*/ |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
32 |
|
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
33 |
import java.io.ByteArrayInputStream; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
34 |
import java.io.IOException; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
35 |
import java.io.InputStream; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
36 |
import java.util.Base64; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
37 |
import javax.imageio.IIOException; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
38 |
import javax.imageio.ImageIO; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
39 |
|
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
40 |
public class JpegTablesOnlyReadTest { |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
41 |
// JPEG input stream containing tables-only image |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
42 |
private static String inputImageBase64 = "/9j/4IAQSkZJRgABAQEASABIAAD" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
43 |
+ "/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI//////////////////////" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
44 |
+ "//////////////////////////////2wBDAVVaWnhpeOuCguv//////////////" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
45 |
+ "///////////////////////////////////////////////////////////wAAR" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
46 |
+ "CAAgACADASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECA//EACUQAQA" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
47 |
+ "CAAUDBAMAAAAAAAAAAAEAAhESITGxQXKSA2Fi0SIyUf/EABYBAQEBAAAAAAAAAA" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
48 |
+ "AAAAAAAAABA//EABcRAQEBAQAAAAAAAAAAAAAAAAEAESH/2gAMAwEAAhEDEQA/A" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
49 |
+ "Nf2VW2OKaWTqnRhl97eb9wrs91uWPEBUX+EtmrssvvbzfuJWjVG2tg1svLLtgJ0" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
50 |
+ "Uxwmd96d5zE7tVdnutyxm5JVoo0u6rpXHdWLP8PU8WIjtRuvVZN96d5zDP8AD1P" |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
51 |
+ "Fhre1Apc/Ida4RAdv/9k="; |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
52 |
|
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
53 |
public static void main(String[] args) throws IOException { |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
54 |
byte[] inputBytes = Base64.getDecoder().decode(inputImageBase64); |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
55 |
InputStream in = new ByteArrayInputStream(inputBytes); |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
56 |
|
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
57 |
// Read tables-only JPEG image |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
58 |
try { |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
59 |
ImageIO.read(in); |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
60 |
} catch (IIOException e) { |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
61 |
// do nothing we expect it to throw IIOException if it throws |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
62 |
// any other exception test will fail. |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
63 |
} |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
64 |
} |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
65 |
} |
2ea3667af41d
8191073: JpegImageReader throws IndexOutOfBoundsException when trying to read image data from tables-only image
jdv
parents:
diff
changeset
|
66 |