diff options
| author | rppicomidi <[email protected]> | 2025-09-06 06:58:35 -0700 |
|---|---|---|
| committer | rppicomidi <[email protected]> | 2025-09-06 06:58:35 -0700 |
| commit | 0263cfc01ab63d6799e80cbbf691af1979cf3ab7 (patch) | |
| tree | e33b8a0df32afb11701a8470a3a6034a4aa1b8e0 | |
| parent | 8304587d7774526a03c6881d11e6d6208fe759be (diff) | |
fix #3239: discard poorly formed packets
| -rw-r--r-- | src/class/midi/midi_host.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/class/midi/midi_host.c b/src/class/midi/midi_host.c index 50bda1e36..e6ace316c 100644 --- a/src/class/midi/midi_host.c +++ b/src/class/midi/midi_host.c @@ -575,6 +575,11 @@ uint32_t tuh_midi_stream_read(uint8_t idx, uint8_t *p_cable_num, uint8_t *p_buff } } } + else { + // bad packet discard + nread = tu_edpt_stream_read(p_midi->daddr, &p_midi->ep_stream.rx, p_midi->stream_read.buffer, 4); + continue; + } } else if (status < MIDI_STATUS_SYSEX_START) { // then it is a channel message either three bytes or two uint8_t fake_cin = (status & 0xf0) >> 4; @@ -617,6 +622,11 @@ uint32_t tuh_midi_stream_read(uint8_t idx, uint8_t *p_cable_num, uint8_t *p_buff bytes_to_add_to_stream = 1; } } + else { + // bad packet discard + nread = tu_edpt_stream_read(p_midi->daddr, &p_midi->ep_stream.rx, p_midi->stream_read.buffer, 4); + continue; + } for (uint8_t i = 1; i <= bytes_to_add_to_stream; i++) { *p_buffer++ = p_midi->stream_read.buffer[i]; |
