Each message has a specific length (most often it's 3), so only work with that number of bytes in the buffer.
Use a more descriptive name when searching for messages.
The length attribute of the MIDIMessage should be upper-cased to indicate its static nature.