Fix ble parsing with zero padded advertisements (#4162)

This commit is contained in:
Jesse Hills 2022-12-08 13:39:33 +13:00
parent 4be7cd12a1
commit 21679cf2ba
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -705,8 +705,13 @@ void ESPBTDevice::parse_adv_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_p
while (offset + 2 < len) {
const uint8_t field_length = payload[offset++]; // First byte is length of adv record
if (field_length == 0)
if (field_length == 0) {
if (offset < param.adv_data_len && param.scan_rsp_len > 0) { // Zero padded advertisement data
offset = param.adv_data_len;
continue;
}
break;
}
// first byte of adv record is adv record type
const uint8_t record_type = payload[offset++];