Added another safety check, and fixed range checking on System Exclusive messages

CQTexperiment
Chris Moeller 2013-10-27 06:17:33 -07:00
parent 969ec470e4
commit 117c574bbb
1 changed files with 2 additions and 1 deletions

View File

@ -31,6 +31,7 @@ bool midi_processor::process_standard_midi_track( std::vector<uint8_t>::const_it
} }
current_timestamp += delta; current_timestamp += delta;
if ( it == end ) return false;
unsigned char event_code = *it++; unsigned char event_code = *it++;
unsigned data_bytes_read = 0; unsigned data_bytes_read = 0;
if ( event_code < 0x80 ) if ( event_code < 0x80 )
@ -65,7 +66,7 @@ bool midi_processor::process_standard_midi_track( std::vector<uint8_t>::const_it
{ {
int data_count = decode_delta( it, end ); int data_count = decode_delta( it, end );
if ( data_count < 0 ) return false; /*throw exception_io_data( "Invalid System Exclusive message" );*/ if ( data_count < 0 ) return false; /*throw exception_io_data( "Invalid System Exclusive message" );*/
if ( end - it > data_count ) return false; if ( end - it < data_count ) return false;
buffer.resize( data_count + 1 ); buffer.resize( data_count + 1 );
buffer[ 0 ] = 0xF0; buffer[ 0 ] = 0xF0;
std::copy( it, it + data_count, buffer.begin() + 1 ); std::copy( it, it + data_count, buffer.begin() + 1 );