Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid null delegate usage attempts in media clusters #20853

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ endpoint 0 {
ram attribute lastNetworkingStatus;
ram attribute lastNetworkID;
ram attribute lastConnectErrorValue;
ram attribute featureMap default = 2;
ram attribute featureMap default = 4;
ram attribute clusterRevision default = 1;
}

Expand Down
178 changes: 10 additions & 168 deletions examples/tv-app/tv-common/tv-app.zap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"featureLevel": 71,
"featureLevel": 75,
"creator": "zap",
"keyValuePairs": [
{
Expand All @@ -19,14 +19,16 @@
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl.json",
"version": "ZCL Test Data",
"type": "zcl-properties"
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"version": "chip-v1",
"type": "gen-templates-json"
"type": "gen-templates-json",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down Expand Up @@ -2131,7 +2133,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "4",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -2343,7 +2345,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "4",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -6961,166 +6963,6 @@
}
]
},
{
"name": "IAS Zone",
"code": 1280,
"mfgCode": null,
"define": "IAS_ZONE_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [
{
"name": "ZoneEnrollResponse",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "client",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "IAS Zone",
"code": 1280,
"mfgCode": null,
"define": "IAS_ZONE_CLUSTER",
"side": "server",
"enabled": 0,
"commands": [
{
"name": "ZoneStatusChangeNotification",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
},
{
"name": "ZoneEnrollRequest",
"code": 1,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
],
"attributes": [
{
"name": "zone state",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "enum8",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "zone type",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "enum16",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "zone status",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "bitmap16",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0000",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "IAS CIE address",
"code": 16,
"mfgCode": null,
"side": "server",
"type": "node_id",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "Zone ID",
"code": 17,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xff",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Test Cluster",
"code": 4294048773,
Expand Down Expand Up @@ -12529,4 +12371,4 @@
}
],
"log": []
}
}
23 changes: 16 additions & 7 deletions src/app/clusters/account-login-server/account-login-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,41 +136,50 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
auto & tempAccountIdentifier = commandData.tempAccountIdentifier;
auto & setupPin = commandData.setupPIN;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleLogin(tempAccountIdentifier, setupPin))
{
status = EMBER_ZCL_STATUS_NOT_AUTHORIZED;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAccountLoginClusterLoginCallback error: %s", err.AsString());
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE);
lazarkov marked this conversation as resolved.
Show resolved Hide resolved
}

bool isLoggedIn = delegate->HandleLogin(tempAccountIdentifier, setupPin);
EmberAfStatus status = isLoggedIn ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_NOT_AUTHORIZED;
emberAfSendImmediateDefaultResponse(status);
return true;
}

bool emberAfAccountLoginClusterLogoutCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::Logout::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleLogout())
{
status = EMBER_ZCL_STATUS_FAILURE;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAccountLoginClusterLogoutCallback error: %s", err.AsString());
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE);
}

bool isLoggedOut = delegate->HandleLogout();
EmberAfStatus status = isLoggedOut ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_NOT_AUTHORIZED;
emberAfSendImmediateDefaultResponse(status);
return true;
}
Expand Down
41 changes: 28 additions & 13 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,30 @@ bool emberAfAudioOutputClusterRenameOutputCallback(app::CommandHandler * command
Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

exit:
if (HasFeature(endpoint, AudioOutputFeature::kNameUpdates) && err == CHIP_NO_ERROR)
if (!HasFeature(endpoint, AudioOutputFeature::kNameUpdates))
{
ChipLogError(Zcl, "AudioOutput no name updates feature");
err = CHIP_ERROR_INCORRECT_STATE;
ExitNow();
}

Protocols::InteractionModel::Status status;

if (delegate->HandleRenameOutput(index, name))
{
bool success = delegate->HandleRenameOutput(index, name);
Protocols::InteractionModel::Status status =
success ? Protocols::InteractionModel::Status::Success : Protocols::InteractionModel::Status::Failure;
command->AddStatus(commandPath, status);
status = Protocols::InteractionModel::Status::Success;
}
else
{
err != CHIP_NO_ERROR ? ChipLogError(Zcl, "emberAfAudioOutputClusterRenameOutputCallback error: %s", err.AsString())
: ChipLogError(Zcl, "AudioOutput no name updates feature");
status = Protocols::InteractionModel::Status::Failure;
}
command->AddStatus(commandPath, status);

exit:

if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAudioOutputClusterRenameOutputCallback error: %s", err.AsString());
command->AddStatus(commandPath, Protocols::InteractionModel::Status::Failure);
}

Expand All @@ -201,22 +212,26 @@ bool emberAfAudioOutputClusterRenameOutputCallback(app::CommandHandler * command
bool emberAfAudioOutputClusterSelectOutputCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
const Commands::SelectOutput::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
auto & index = commandData.index;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
auto & index = commandData.index;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleSelectOutput(index))
{
status = EMBER_ZCL_STATUS_FAILURE;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAudioOutputClusterSelectOutputCallback error: %s", err.AsString());
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE);
}

bool success = delegate->HandleSelectOutput(index);
EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE;
emberAfSendImmediateDefaultResponse(status);
return true;
}
Expand Down
Loading