Skip to content

Commit

Permalink
check for inlen of at least 2 at the beginning for midi meta events.
Browse files Browse the repository at this point in the history
otherwise we would read beyond bounds with bad (short) midis. commit
ad6d7cf was mistaken this way.
  • Loading branch information
sezero committed Mar 10, 2018
1 parent 544c8a1 commit 7b87c60
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/internal_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,9 @@ uint32_t _WM_SetupMidiEvent(struct _mdi *mdi, uint8_t * event_data, uint32_t inp
MIDI Meta Events
*/
uint32_t tmp_length = 0;

if (input_length < 2)
goto shortbuf;
if ((event_data[0] == 0x00) && (event_data[1] == 0x02)) {
/*
Sequence Number
Expand Down Expand Up @@ -2286,7 +2289,6 @@ uint32_t _WM_SetupMidiEvent(struct _mdi *mdi, uint8_t * event_data, uint32_t inp
Deal with this inside calling function
We only setting this up here for _WM_Event2Midi function
*/
if (input_length < 2) goto shortbuf;
_WM_midi_setup_endoftrack(mdi);
ret_cnt += 2;
} else if ((event_data[0] == 0x51) && (event_data[1] == 0x03)) {
Expand Down

0 comments on commit 7b87c60

Please sign in to comment.