Skip to content

Commit 3a2dc69

Browse files
fix not updating size of array
1 parent 8c26e46 commit 3a2dc69

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

features/FEATURE_BLE/ble/generic/SecurityDb.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,28 +584,32 @@ class SecurityDb {
584584
WhitelistDbCb_t cb,
585585
::Gap::Whitelist_t *whitelist
586586
) {
587-
for (size_t i = 0; i < get_entry_count() && i < whitelist->capacity; i++) {
587+
for (size_t i = 0; i < get_entry_count() && whitelist->size < whitelist->capacity; i++) {
588588
entry_handle_t db_handle = get_entry_handle_by_index(i);
589589
SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle);
590590

591591
if (!flags) {
592592
continue;
593593
}
594594

595+
SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle);
596+
if (!identity) {
597+
continue;
598+
}
599+
600+
memcpy(
601+
whitelist->addresses[whitelist->size].address,
602+
identity->identity_address.data(),
603+
sizeof(BLEProtocol::AddressBytes_t)
604+
);
605+
595606
if (flags->peer_address_is_public) {
596-
whitelist->addresses[i].type = BLEProtocol::AddressType::PUBLIC;
607+
whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::PUBLIC;
597608
} else {
598-
whitelist->addresses[i].type = BLEProtocol::AddressType::RANDOM_STATIC;
609+
whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::RANDOM_STATIC;
599610
}
600611

601-
SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle);
602-
if (identity) {
603-
memcpy(
604-
whitelist->addresses[i].address,
605-
identity->identity_address.data(),
606-
sizeof(BLEProtocol::AddressBytes_t)
607-
);
608-
}
612+
whitelist->size++;
609613
}
610614

611615
cb(whitelist);

0 commit comments

Comments
 (0)