src/share/classes/com/sun/media/sound/AiffFileReader.java
Print this page
@@ -49,19 +49,10 @@
*/
public final class AiffFileReader extends SunFileReader {
private static final int MAX_READ_LENGTH = 8;
- /**
- * Constructs a new AiffParser object.
- */
- public AiffFileReader() {
- }
-
-
-
-
// METHODS TO IMPLEMENT AudioFileReader
/**
* Obtains the audio file format of the input stream provided. The stream must
* point to valid audio file data. In general, audio file providers may
@@ -290,13 +281,19 @@
// $$fb: fix for 4399551: Repost of bug candidate: cannot replay aif file (Review ID: 108108)
if ((!aifc && chunkLen < 18) || (aifc && chunkLen < 22)) {
throw new UnsupportedAudioFileException("Invalid AIFF/COMM chunksize");
}
// Read header info.
- int channels = dis.readShort();
- dis.readInt();
- int sampleSizeInBits = dis.readShort();
+ int channels = dis.readUnsignedShort();
+ if (channels <= 0) {
+ throw new UnsupportedAudioFileException("Invalid number of channels");
+ }
+ dis.readInt(); // numSampleFrames
+ int sampleSizeInBits = dis.readUnsignedShort();
+ if (sampleSizeInBits < 1 || sampleSizeInBits > 32) {
+ throw new UnsupportedAudioFileException("Invalid AIFF/COMM sampleSize");
+ }
float sampleRate = (float) read_ieee_extended(dis);
chunkRead += (2 + 4 + 2 + 10);
// If this is not AIFC then we assume it's
// a linearly encoded file.
@@ -436,9 +433,6 @@
}
}
return f;
}
-
-
-
}