Skip to content

Commit f1ba0c0

Browse files
committed
AP_ADSB: avoid buffer overwrite in AP_ADSB_Sagetech_MXS
we were not bounds-checking the off-wire length, and then reading many bytes into a target buffer based on it. Do the bounds check. Also remove the writing of the checksum into the payload buffer - this was the notional 1-byte overwrite
1 parent 124ebed commit f1ba0c0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

libraries/AP_ADSB/AP_ADSB_Sagetech_MXS.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ bool AP_ADSB_Sagetech_MXS::parse_byte(const uint8_t data)
279279
case ParseState::WaitingFor_PayloadLen:
280280
message_in.checksum += data;
281281
message_in.packet.payload_length = data;
282+
// the checksum is also appended to the payload array, so
283+
// we only allow a 254 byte payload here:
284+
if (message_in.packet.payload_length >= ARRAY_SIZE(message_in.packet.payload)) {
285+
message_in.state = ParseState::WaitingFor_Start;
286+
break;
287+
}
282288
message_in.index = 0;
283289
message_in.state = (data == 0) ? ParseState::WaitingFor_Checksum : ParseState::WaitingFor_PayloadContents;
284290
break;

0 commit comments

Comments
 (0)