Skip to content

Commit db29102

Browse files
committed
test for mallformed packages
1 parent ee56ae8 commit db29102

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/AppleMIDI_Defs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ enum parserReturn: uint8_t
3131
Processed,
3232
NotSureGiveMeMoreData,
3333
NotEnoughData,
34-
UnexpectedData,
34+
UnexpectedData,
35+
UnexpectedMidiData,
3536
};
3637

3738
#if defined(__AVR__)

src/rtpMIDI_Parser_MidiCommandSection.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ parserReturn decodeMidiSection(RtpBuffer_t &buffer)
3434
return parserReturn::NotEnoughData;
3535
}
3636

37+
if (consumed > midiCommandLength) {
38+
buffer.clear();
39+
return parserReturn::UnexpectedMidiData;
40+
}
41+
3742
midiCommandLength -= consumed;
3843

3944
while (consumed--)

0 commit comments

Comments
 (0)