File tree Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -584,28 +584,32 @@ class SecurityDb {
584
584
WhitelistDbCb_t cb,
585
585
::Gap::Whitelist_t *whitelist
586
586
) {
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++) {
588
588
entry_handle_t db_handle = get_entry_handle_by_index (i);
589
589
SecurityDistributionFlags_t* flags = get_distribution_flags (db_handle);
590
590
591
591
if (!flags) {
592
592
continue ;
593
593
}
594
594
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
+
595
606
if (flags->peer_address_is_public ) {
596
- whitelist->addresses [i ].type = BLEProtocol::AddressType::PUBLIC;
607
+ whitelist->addresses [whitelist-> size ].type = BLEProtocol::AddressType::PUBLIC;
597
608
} else {
598
- whitelist->addresses [i ].type = BLEProtocol::AddressType::RANDOM_STATIC;
609
+ whitelist->addresses [whitelist-> size ].type = BLEProtocol::AddressType::RANDOM_STATIC;
599
610
}
600
611
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 ++;
609
613
}
610
614
611
615
cb (whitelist);
Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ ble_error_t GenericSecurityManager::purgeAllBondingState(void) {
142
142
ble_error_t GenericSecurityManager::generateWhitelistFromBondTable (Gap::Whitelist_t *whitelist) const {
143
143
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
144
144
if (eventHandler) {
145
+ if (!whitelist) {
146
+ return BLE_ERROR_INVALID_PARAM;
147
+ }
145
148
_db->generate_whitelist_from_bond_table (
146
149
mbed::callback (eventHandler, &::SecurityManager::EventHandler::whitelistFromBondTable),
147
150
whitelist
You can’t perform that action at this time.
0 commit comments