Skip to content

Commit

Permalink
LD19/LD06 data length sanity check fix
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Borowski <[email protected]>
  • Loading branch information
Adam Borowski committed Feb 25, 2025
1 parent aef8f9d commit 8625163
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/AP_Proximity/AP_Proximity_LD06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void AP_Proximity_LD06::get_readings()
}

// total_packet_length = sizeof(header) + datalength + sizeof(footer):
const uint32_t total_packet_length = 6 + 3*_response[START_DATA_LENGTH] + 5;
if (_response[START_DATA_LENGTH] != PAYLOAD_COUNT ||
const uint32_t total_packet_length = 6 + 3*(_response[START_DATA_LENGTH] & 0x1F) + 5;
if ((_response[START_DATA_LENGTH] & 0x1F) != PAYLOAD_COUNT ||
total_packet_length > ARRAY_SIZE(_response)) {
// invalid packet received; throw away all data and
// start again.
Expand Down

0 comments on commit 8625163

Please sign in to comment.