AP_RCProtocol: fixed underflow wrap in GHST

This commit is contained in:
Andrew Tridgell 2024-04-07 08:48:07 +10:00 committed by Peter Barker
parent 5a2f711d85
commit 4933ef3f2d
1 changed files with 6 additions and 0 deletions

View File

@ -177,6 +177,12 @@ void AP_RCProtocol_GHST::_process_byte(uint32_t timestamp_us, uint8_t byte)
return;
}
if (_frame.length < 2) {
// invalid length, we subtract 2 below
_frame_ofs = 0;
return;
}
// decode whatever we got and expect
if (_frame_ofs == _frame.length + GHST_HEADER_LEN) {
log_data(AP_RCProtocol::GHST, timestamp_us, (const uint8_t*)&_frame, _frame_ofs - GHST_HEADER_LEN);