mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-12 02:44:00 -04:00
AP_Proximity: correct length sanity check
the length field is actually the count of 3-byte data elements
This commit is contained in:
parent
3639fa6d17
commit
54a36170e4
@ -106,8 +106,10 @@ void AP_Proximity_LD06::get_readings()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t total_packet_length = _response[START_DATA_LENGTH] + 3;
|
// total_packet_length = sizeof(header) + datalength + sizeof(footer):
|
||||||
if (total_packet_length > ARRAY_SIZE(_response)) {
|
const uint32_t total_packet_length = 6 + 3*_response[START_DATA_LENGTH] + 5;
|
||||||
|
if (_response[START_DATA_LENGTH] != PAYLOAD_COUNT ||
|
||||||
|
total_packet_length > ARRAY_SIZE(_response)) {
|
||||||
// invalid packet received; throw away all data and
|
// invalid packet received; throw away all data and
|
||||||
// start again.
|
// start again.
|
||||||
_byte_count = 0;
|
_byte_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user