@@ -448,7 +448,7 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:
448
448
return false ;
449
449
}
450
450
451
- memcpy (mUserInStorage .userName , userName.data (), userName.size ());
451
+ memmove (mUserInStorage .userName , userName.data (), userName.size ());
452
452
mUserInStorage .userNameSize = userName.size ();
453
453
mUserInStorage .userUniqueId = uniqueId;
454
454
mUserInStorage .userStatus = userStatus;
@@ -586,7 +586,7 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
586
586
mCredentialInStorage .lastModifiedBy = modifier;
587
587
mCredentialInStorage .credentialDataSize = credentialData.size ();
588
588
589
- memcpy (mCredentialInStorage .credentialData , credentialData.data (), mCredentialInStorage .credentialDataSize );
589
+ memmove (mCredentialInStorage .credentialData , credentialData.data (), mCredentialInStorage .credentialDataSize );
590
590
591
591
chip::StorageKeyName key = LockCredentialEndpoint (credentialIndex, credentialType, endpointId);
592
592
@@ -952,16 +952,17 @@ bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip:
952
952
continue ;
953
953
}
954
954
955
- for (int j = 0 ; j < mUserInStorage .currentCredentialCount ; j++)
955
+ // Loop through each credential attached to the user
956
+ for (int userCredentialIndex = 0 ; userCredentialIndex < mUserInStorage .currentCredentialCount ; userCredentialIndex++)
956
957
{
957
958
// If the current credential is a pin type, then check it against pin input. Otherwise ignore
958
- if (mCredentials [j ].credentialType == CredentialTypeEnum::kPin )
959
+ if (mCredentials [userCredentialIndex ].credentialType == CredentialTypeEnum::kPin )
959
960
{
960
961
// Read the individual credential at credentialIndex j
961
962
uint16_t credentialSize = static_cast <uint16_t >(sizeof (LockCredentialInfo));
962
963
963
964
chip::StorageKeyName key =
964
- LockCredentialEndpoint (mCredentials [j ].credentialIndex , mCredentials [j ].credentialType , endpointId);
965
+ LockCredentialEndpoint (mCredentials [userCredentialIndex ].credentialIndex , mCredentials [userCredentialIndex ].credentialType , endpointId);
965
966
966
967
error = mStorage ->SyncGetKeyValue (key.KeyName (), &mCredentialInStorage , credentialSize);
967
968
@@ -986,7 +987,7 @@ bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip:
986
987
Zcl, " Lock App: specified PIN code was found in the database, setting lock state to \" %s\" [endpointId=%d]" ,
987
988
lockStateToString (lockState), endpointId);
988
989
989
- LockOpCredentials userCredential[] = { { CredentialTypeEnum::kPin , mCredentials [j ].credentialIndex } };
990
+ LockOpCredentials userCredential[] = { { CredentialTypeEnum::kPin , mCredentials [userCredentialIndex ].credentialIndex } };
990
991
auto userCredentials = MakeNullable<List<const LockOpCredentials>>(userCredential);
991
992
992
993
DoorLockServer::Instance ().SetLockState (endpointId, lockState, OperationSourceEnum::kRemote , userIndex,
0 commit comments