author | serb |
Mon, 31 Oct 2016 14:50:09 +0300 | |
changeset 41905 | e8e5df013c6e |
parent 41394 | da0318151636 |
permissions | -rw-r--r-- |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
1 |
/* |
41394 | 2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
4 |
* |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
8 |
* |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
14 |
* |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
18 |
* |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
21 |
* questions. |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
22 |
*/ |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
23 |
|
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
24 |
import java.io.ByteArrayInputStream; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
25 |
import java.io.IOException; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
26 |
import java.io.InputStream; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
27 |
|
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
28 |
import javax.sound.sampled.AudioSystem; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
29 |
import javax.sound.sampled.UnsupportedAudioFileException; |
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
30 |
import javax.sound.sampled.spi.AudioFileReader; |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
31 |
|
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
32 |
import static java.util.ServiceLoader.load; |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
33 |
|
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
34 |
/** |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
35 |
* @test |
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
36 |
* @bug 7058662 7058666 7058672 8130305 |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
37 |
* @author Sergey Bylokhov |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
38 |
*/ |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
39 |
public final class ReadersExceptions { |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
40 |
|
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
41 |
// empty channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
42 |
static byte[] wrongAIFFCh = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
43 |
{0x46, 0x4f, 0x52, 0x4d, // AiffFileFormat.AIFF_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
44 |
0, 0, 0, 0, // length |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
45 |
0, 0, 0, 0, // iffType |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
46 |
0x43, 0x4f, 0x4d, 0x4d, // chunkName |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
47 |
0, 0, 0, 100, // chunkLen |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
48 |
0, 0, // channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
49 |
0, 0, 0, 0, // |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
50 |
0, 10 // sampleSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
51 |
, 0, 0, 0, 0}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
52 |
// empty sampleSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
53 |
static byte[] wrongAIFFSSL = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
54 |
{0x46, 0x4f, 0x52, 0x4d, //AiffFileFormat.AIFF_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
55 |
0, 0, 0, 0, // length |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
56 |
0, 0, 0, 0, // iffType |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
57 |
0x43, 0x4f, 0x4d, 0x4d, // chunkName |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
58 |
0, 0, 0, 100, // chunkLen |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
59 |
0, 10, // channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
60 |
0, 0, 0, 0, // |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
61 |
0, 0 // sampleSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
62 |
, 0, 0, 0, 0}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
63 |
// big sampleSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
64 |
static byte[] wrongAIFFSSH = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
65 |
{0x46, 0x4f, 0x52, 0x4d, //AiffFileFormat.AIFF_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
66 |
0, 0, 0, 0, // length |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
67 |
0, 0, 0, 0, // iffType |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
68 |
0x43, 0x4f, 0x4d, 0x4d, // chunkName |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
69 |
0, 0, 0, 100, // chunkLen |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
70 |
0, 10, // channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
71 |
0, 0, 0, 0, // |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
72 |
0, 33 // sampleSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
73 |
, 0, 0, 0, 0}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
74 |
// empty channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
75 |
static byte[] wrongAUCh = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
76 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
41394 | 77 |
0, 0, 0, 24, // headerSize |
78 |
0, 0, 0, 0, // dataSize |
|
79 |
0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8 |
|
80 |
0, 0, 0, 1, // sampleRate |
|
81 |
0, 0, 0, 0 // channels |
|
82 |
}; |
|
83 |
// empty sample rate |
|
84 |
static byte[] wrongAUSR = |
|
85 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
|
86 |
0, 0, 0, 24, // headerSize |
|
87 |
0, 0, 0, 0, // dataSize |
|
88 |
0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8 |
|
89 |
0, 0, 0, 0, // sampleRate |
|
90 |
0, 0, 0, 1 // channels |
|
91 |
}; |
|
92 |
// empty header size |
|
93 |
static byte[] wrongAUEmptyHeader = |
|
94 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
|
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
95 |
0, 0, 0, 0, // headerSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
96 |
0, 0, 0, 0, // dataSize |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
97 |
0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8 |
41394 | 98 |
0, 0, 0, 1, // sampleRate |
99 |
0, 0, 0, 1 // channels |
|
100 |
}; |
|
101 |
// small header size |
|
102 |
static byte[] wrongAUSmallHeader = |
|
103 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
|
104 |
0, 0, 0, 7, // headerSize |
|
105 |
0, 0, 0, 0, // dataSize |
|
106 |
0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8 |
|
107 |
0, 0, 0, 1, // sampleRate |
|
108 |
0, 0, 0, 1 // channels |
|
109 |
}; |
|
110 |
// frame size overflow, when result negative |
|
111 |
static byte[] wrongAUFrameSizeOverflowNegativeResult = |
|
112 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
|
113 |
0, 0, 0, 24, // headerSize |
|
114 |
0, 0, 0, 0, // dataSize |
|
115 |
0, 0, 0, 5, // encoding_local AuFileFormat.AU_LINEAR_32 |
|
116 |
0, 0, 0, 1, // sampleRate |
|
117 |
0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF // channels |
|
118 |
}; |
|
119 |
// frame size overflow, when result positive |
|
120 |
static byte[] wrongAUFrameSizeOverflowPositiveResult = |
|
121 |
{0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC |
|
122 |
0, 0, 0, 24, // headerSize |
|
123 |
0, 0, 0, 0, // dataSize |
|
124 |
0, 0, 0, 4, // encoding_local AuFileFormat.AU_LINEAR_24 |
|
125 |
0, 0, 0, 1, // sampleRate |
|
126 |
0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF // channels |
|
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
127 |
}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
128 |
// empty channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
129 |
static byte[] wrongWAVCh = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
130 |
{0x52, 0x49, 0x46, 0x46, // WaveFileFormat.RIFF_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
131 |
1, 1, 1, 1, // fileLength |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
132 |
0x57, 0x41, 0x56, 0x45, // waveMagic |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
133 |
0x66, 0x6d, 0x74, 0x20, // FMT_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
134 |
3, 0, 0, 0, // length |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
135 |
1, 0, // wav_type WAVE_FORMAT_PCM |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
136 |
0, 0, // channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
137 |
0, 0, 0, 0, // sampleRate |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
138 |
0, 0, 0, 0, // avgBytesPerSec |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
139 |
0, 0, // blockAlign |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
140 |
1, 0, // sampleSizeInBits |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
141 |
0x64, 0x61, 0x74, 0x61, // WaveFileFormat.DATA_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
142 |
0, 0, 0, 0, // dataLength |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
143 |
}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
144 |
// empty sampleSizeInBits |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
145 |
static byte[] wrongWAVSSB = |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
146 |
{0x52, 0x49, 0x46, 0x46, // WaveFileFormat.RIFF_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
147 |
1, 1, 1, 1, // fileLength |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
148 |
0x57, 0x41, 0x56, 0x45, // waveMagic |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
149 |
0x66, 0x6d, 0x74, 0x20, // FMT_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
150 |
3, 0, 0, 0, // length |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
151 |
1, 0, // wav_type WAVE_FORMAT_PCM |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
152 |
1, 0, // channels |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
153 |
0, 0, 0, 0, // sampleRate |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
154 |
0, 0, 0, 0, // avgBytesPerSec |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
155 |
0, 0, // blockAlign |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
156 |
0, 0, // sampleSizeInBits |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
157 |
0x64, 0x61, 0x74, 0x61, // WaveFileFormat.DATA_MAGIC |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
158 |
0, 0, 0, 0, // dataLength |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
159 |
}; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
160 |
|
41394 | 161 |
static byte[][] data = { |
162 |
wrongAIFFCh, wrongAIFFSSL, wrongAIFFSSH, wrongAUCh, wrongAUSR, |
|
163 |
wrongAUEmptyHeader, wrongAUSmallHeader, |
|
164 |
wrongAUFrameSizeOverflowNegativeResult, |
|
165 |
wrongAUFrameSizeOverflowPositiveResult, wrongWAVCh, wrongWAVSSB |
|
166 |
}; |
|
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
167 |
|
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
168 |
public static void main(final String[] args) throws IOException { |
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
169 |
for (final byte[] bytes : data) { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
170 |
testAS(bytes); |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
171 |
testAFR(bytes); |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
172 |
} |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
173 |
} |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
174 |
|
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
175 |
private static void testAS(final byte[] buffer) throws IOException { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
176 |
// AudioSystem API |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
177 |
final InputStream is = new ByteArrayInputStream(buffer); |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
178 |
try { |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
179 |
AudioSystem.getAudioFileFormat(is); |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
180 |
} catch (UnsupportedAudioFileException ignored) { |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
181 |
// Expected. |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
182 |
return; |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
183 |
} |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
184 |
throw new RuntimeException("Test Failed"); |
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
185 |
} |
32121
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
186 |
|
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
187 |
private static void testAFR(final byte[] buffer) throws IOException { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
188 |
// AudioFileReader API |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
189 |
final InputStream is = new ByteArrayInputStream(buffer); |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
190 |
for (final AudioFileReader afr : load(AudioFileReader.class)) { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
191 |
for (int i = 0; i < 10; ++i) { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
192 |
try { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
193 |
afr.getAudioFileFormat(is); |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
194 |
throw new RuntimeException("UAFE expected"); |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
195 |
} catch (final UnsupportedAudioFileException ignored) { |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
196 |
// Expected. |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
197 |
} |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
198 |
} |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
199 |
} |
93ad23865c9e
8013586: audioInputStream.close() does not release the resource
serb
parents:
21245
diff
changeset
|
200 |
} |
21245
786207514920
7058662: AiffFileReader throws java.lang.ArithmeticException: division by zero when frame size is zero
serb
parents:
diff
changeset
|
201 |
} |