Skip to content

Commit

Permalink
8283190: Improve MIDI processing
Browse files Browse the repository at this point in the history
Reviewed-by: prr, rhalade, psadhukhan, mschoene
  • Loading branch information
Alexander Zuev authored and slowhog committed Jul 19, 2022
1 parent 632d2d2 commit a37465b
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -367,6 +367,11 @@ void readTrack(Track track) throws IOException, InvalidMidiDataException {
case 0xF7:
// sys ex
int sysexLength = (int) readVarInt();
if (sysexLength < 0 || sysexLength > trackLength - pos) {
throw new InvalidMidiDataException("Message length is out of bounds: "
+ sysexLength);
}

byte[] sysexData = new byte[sysexLength];
read(sysexData);

Expand All @@ -379,8 +384,8 @@ void readTrack(Track track) throws IOException, InvalidMidiDataException {
// meta
int metaType = readUnsigned();
int metaLength = (int) readVarInt();
if (metaLength < 0) {
throw new InvalidMidiDataException("length out of bounds: "
if (metaLength < 0 || metaLength > trackLength - pos) {
throw new InvalidMidiDataException("Message length is out of bounds: "
+ metaLength);
}
final byte[] metaData;
Expand Down

0 comments on commit a37465b

Please sign in to comment.