Skip to content

Commit

Permalink
AP_RCProtocol: fixed underflow wrap in GHST
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Apr 6, 2024
1 parent b0042c1 commit 37fb9b3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_GHST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37fb9b3

Please sign in to comment.