@@ -327,6 +327,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember
327
327
328
328
VerifyOrReturnValue (IsValidUserIndex (userIndex), false );
329
329
330
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
331
+
330
332
ChipLogProgress (Zcl, " Door Lock App: LockManager::GetUser [endpoint=%d,userIndex=%hu]" , endpointId, userIndex);
331
333
332
334
chip::StorageKeyName userKey = LockUserEndpoint (userIndex, endpointId);
@@ -419,14 +421,14 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:
419
421
endpointId, userIndex, creator, modifier, userName.data (), uniqueId, to_underlying (userStatus),
420
422
to_underlying (usertype), to_underlying (credentialRule), credentials, totalCredentials);
421
423
424
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
425
+
422
426
VerifyOrReturnValue (userIndex > 0 , false ); // indices are one-indexed
423
427
424
428
userIndex--;
425
429
426
430
VerifyOrReturnValue (IsValidUserIndex (userIndex), false );
427
431
428
- VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
429
-
430
432
if (userName.size () > DOOR_LOCK_MAX_USER_NAME_SIZE)
431
433
{
432
434
ChipLogError (Zcl, " Cannot set user - user name is too long [endpoint=%d,index=%d]" , endpointId, userIndex);
@@ -485,6 +487,8 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential
485
487
{
486
488
CHIP_ERROR error;
487
489
490
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
491
+
488
492
VerifyOrReturnValue (IsValidCredentialType (credentialType), false );
489
493
490
494
if (CredentialTypeEnum::kProgrammingPIN == credentialType)
@@ -552,6 +556,8 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
552
556
{
553
557
CHIP_ERROR error;
554
558
559
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
560
+
555
561
VerifyOrReturnValue (IsValidCredentialType (credentialType), false );
556
562
557
563
if (CredentialTypeEnum::kProgrammingPIN == credentialType)
@@ -588,6 +594,9 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
588
594
chip::Server::GetInstance ().GetPersistentStorage ().SyncSetKeyValue (key.KeyName (), &credentialInStorage,
589
595
static_cast <uint16_t >(sizeof (LockCredentialInfo)));
590
596
597
+ // Clear credentialInStorage.credentialData
598
+ memset (credentialInStorage.credentialData , 0 , sizeof (uint8_t )*kMaxCredentialSize );
599
+
591
600
if ((error != CHIP_NO_ERROR))
592
601
{
593
602
ChipLogError (Zcl, " Error reading from KVS key" );
@@ -604,6 +613,8 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we
604
613
{
605
614
CHIP_ERROR error;
606
615
616
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
617
+
607
618
VerifyOrReturnValue (weekdayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
608
619
VerifyOrReturnValue (userIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
609
620
@@ -653,6 +664,8 @@ DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we
653
664
{
654
665
CHIP_ERROR error;
655
666
667
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
668
+
656
669
VerifyOrReturnValue (weekdayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
657
670
VerifyOrReturnValue (userIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
658
671
@@ -689,6 +702,8 @@ DlStatus LockManager::GetYeardaySchedule(chip::EndpointId endpointId, uint8_t ye
689
702
{
690
703
CHIP_ERROR error;
691
704
705
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
706
+
692
707
VerifyOrReturnValue (yearDayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
693
708
VerifyOrReturnValue (userIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
694
709
@@ -737,6 +752,8 @@ DlStatus LockManager::SetYeardaySchedule(chip::EndpointId endpointId, uint8_t ye
737
752
{
738
753
CHIP_ERROR error;
739
754
755
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
756
+
740
757
VerifyOrReturnValue (yearDayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
741
758
VerifyOrReturnValue (userIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
742
759
@@ -770,6 +787,8 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho
770
787
{
771
788
CHIP_ERROR error;
772
789
790
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
791
+
773
792
VerifyOrReturnValue (holidayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
774
793
775
794
holidayIndex--;
@@ -815,6 +834,8 @@ DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho
815
834
{
816
835
CHIP_ERROR error;
817
836
837
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, DlStatus::kFailure );
838
+
818
839
VerifyOrReturnValue (holidayIndex > 0 , DlStatus::kFailure ); // indices are one-indexed
819
840
820
841
holidayIndex--;
@@ -867,6 +888,8 @@ bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip:
867
888
868
889
CHIP_ERROR error;
869
890
891
+ VerifyOrReturnValue (kInvalidEndpointId != endpointId, false );
892
+
870
893
// Assume pin is required until told otherwise
871
894
bool requirePin = true ;
872
895
chip::app::Clusters::DoorLock::Attributes::RequirePINforRemoteOperation::Get (endpointId, &requirePin);
0 commit comments