-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Description
ble::AdvertisingDataParser fails on 31-byte payloads padded with one or two null terminating bytes.
AdvertisingDataParser::hasNext() performs a bounds check in determining if there's more data to process:
if (position >= data.size()) {
return false;
}
However, AdvertisingDataParser::next() indexes further than this into the data span:
(ble::adv_data_type_t::type) data[position + TYPE_INDEX],
data.subspan(position + VALUE_INDEX, current_length() - (TYPE_SIZE))
As a result, when a full-length legacy advertising payload is padded with one or two null terminating bytes at the end, AdvertisingDataParser::hasNext() returns true even after all data has been consumed, and a subsequent call to AdvertisingDataParser::next() overruns the span when it attempts to read either the data type or value.
One fix is to fix the comparison against data.size() in AdvertisingDataParser::hasNext():
if (position + VALUE_INDEX >= data.size()) {
return false;
}
Affects v15.2 (0f959db)
Issue request type
[ ] Question
[ ] Enhancement
[X ] Bug