@@ -376,9 +376,10 @@ void AddSceneParse(CommandHandlerInterface::HandlerContext & ctx, const CommandD
376
376
response.sceneID = req.sceneID ;
377
377
378
378
// Verify the attributes are respecting constraints
379
- if (req.transitionTime > scenes::kScenesMaxTransitionTime || req.sceneName .size () > scenes::kSceneNameMaxLength )
379
+ if (req.transitionTime > scenes::kScenesMaxTransitionTime || req.sceneName .size () > scenes::kSceneNameMaxLength ||
380
+ req.sceneID == scenes::kUndefinedSceneId )
380
381
{
381
- response.status = to_underlying (Protocols::InteractionModel::Status::InvalidCommand );
382
+ response.status = to_underlying (Protocols::InteractionModel::Status::ConstraintError );
382
383
ctx.mCommandHandler .AddResponse (ctx.mRequestPath , response);
383
384
return ;
384
385
}
@@ -483,6 +484,14 @@ void ViewSceneParse(HandlerContext & ctx, const CommandData & req, GroupDataProv
483
484
response.groupID = req.groupID ;
484
485
response.sceneID = req.sceneID ;
485
486
487
+ // Verify the attributes are respecting constraints
488
+ if (req.sceneID == scenes::kUndefinedSceneId )
489
+ {
490
+ response.status = to_underlying (Protocols::InteractionModel::Status::ConstraintError);
491
+ ctx.mCommandHandler .AddResponse (ctx.mRequestPath , response);
492
+ return ;
493
+ }
494
+
486
495
// Verify Endpoint in group
487
496
VerifyOrReturn (nullptr != groupProvider);
488
497
if (0 != req.groupID &&
@@ -830,6 +839,14 @@ void ScenesServer::HandleRemoveScene(HandlerContext & ctx, const Commands::Remov
830
839
response.groupID = req.groupID ;
831
840
response.sceneID = req.sceneID ;
832
841
842
+ // Verify the attributes are respecting constraints
843
+ if (req.sceneID == scenes::kUndefinedSceneId )
844
+ {
845
+ response.status = to_underlying (Protocols::InteractionModel::Status::ConstraintError);
846
+ ctx.mCommandHandler .AddResponse (ctx.mRequestPath , response);
847
+ return ;
848
+ }
849
+
833
850
// Scene Table interface data
834
851
SceneTableEntry scene (SceneStorageId (req.sceneID , req.groupID ));
835
852
@@ -930,6 +947,14 @@ void ScenesServer::HandleStoreScene(HandlerContext & ctx, const Commands::StoreS
930
947
response.groupID = req.groupID ;
931
948
response.sceneID = req.sceneID ;
932
949
950
+ // Verify the attributes are respecting constraints
951
+ if (req.sceneID == scenes::kUndefinedSceneId )
952
+ {
953
+ response.status = to_underlying (Protocols::InteractionModel::Status::ConstraintError);
954
+ ctx.mCommandHandler .AddResponse (ctx.mRequestPath , response);
955
+ return ;
956
+ }
957
+
933
958
CHIP_ERROR err = StoreSceneParse (ctx.mCommandHandler .GetAccessingFabricIndex (), ctx.mRequestPath .mEndpointId , req.groupID ,
934
959
req.sceneID , mGroupProvider );
935
960
@@ -943,6 +968,14 @@ void ScenesServer::HandleStoreScene(HandlerContext & ctx, const Commands::StoreS
943
968
void ScenesServer::HandleRecallScene (HandlerContext & ctx, const Commands::RecallScene::DecodableType & req)
944
969
{
945
970
MATTER_TRACE_SCOPE (" RecallScene" , " Scenes" );
971
+
972
+ // Verify the attributes are respecting constraints
973
+ if (req.sceneID == scenes::kUndefinedSceneId )
974
+ {
975
+ ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::ConstraintError);
976
+ return ;
977
+ }
978
+
946
979
CHIP_ERROR err = RecallSceneParse (ctx.mCommandHandler .GetAccessingFabricIndex (), ctx.mRequestPath .mEndpointId , req.groupID ,
947
980
req.sceneID , req.transitionTime , mGroupProvider );
948
981
@@ -1025,6 +1058,14 @@ void ScenesServer::HandleCopyScene(HandlerContext & ctx, const Commands::CopySce
1025
1058
response.groupIdentifierFrom = req.groupIdentifierFrom ;
1026
1059
response.sceneIdentifierFrom = req.sceneIdentifierFrom ;
1027
1060
1061
+ // Verify the attributes are respecting constraints
1062
+ if (req.sceneIdentifierFrom == scenes::kUndefinedSceneId || req.sceneIdentifierTo == scenes::kUndefinedSceneId )
1063
+ {
1064
+ response.status = to_underlying (Protocols::InteractionModel::Status::ResourceExhausted);
1065
+ ctx.mCommandHandler .AddResponse (ctx.mRequestPath , response);
1066
+ return ;
1067
+ }
1068
+
1028
1069
// Verify Endpoint in group
1029
1070
VerifyOrReturn (nullptr != mGroupProvider );
1030
1071
if ((0 != req.groupIdentifierFrom &&
0 commit comments