fix crash in slave role when storing CSRK

This commit is contained in:
Matthias Ringwald 2015-10-26 23:07:40 +01:00
parent 3ef52a965f
commit 99f948c87f

View File

@ -1012,7 +1012,14 @@ static void sm_key_distribution_handle_all_received(sm_connection_t * sm_conn){
if (le_db_index >= 0){
le_device_db_local_counter_set(le_db_index, 0);
// store CSRK
// store local CSRK
if (setup->sm_key_distribution_send_set & SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION){
log_info("sm: store local CSRK");
le_device_db_local_csrk_set(le_db_index, setup->sm_local_csrk);
le_device_db_local_counter_set(le_db_index, 0);
}
// store remote CSRK
if (setup->sm_key_distribution_received_set & SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION){
log_info("sm: store remote CSRK");
le_device_db_remote_csrk_set(le_db_index, setup->sm_peer_csrk);
@ -1514,8 +1521,6 @@ static void sm_run(void){
uint8_t buffer[17];
buffer[0] = SM_CODE_SIGNING_INFORMATION;
log_info("sm: store local CSRK");
le_device_db_local_csrk_set(connection->sm_le_db_index, setup->sm_local_csrk);
swap128(setup->sm_local_csrk, &buffer[1]);
l2cap_send_connectionless(connection->sm_handle, L2CAP_CID_SECURITY_MANAGER_PROTOCOL, (uint8_t*) buffer, sizeof(buffer));
sm_timeout_reset(connection);