Skip to content

Commit 3569239

Browse files
carol-applepull[bot]
authored andcommitted
[OTA] Validate various error ImageURI cases (#17223)
1 parent b210b68 commit 3569239

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/app/clusters/ota-requestor/DefaultOTARequestor.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,32 @@ void DefaultOTARequestor::OnQueryImageResponse(void * context, const QueryImageR
152152

153153
if (err != CHIP_NO_ERROR)
154154
{
155+
ChipLogError(SoftwareUpdate, "QueryImageResponse contains invalid fields: %" CHIP_ERROR_FORMAT, err.Format());
155156
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, err);
156157
return;
157158
}
158159

160+
// This should never happen since receiving a response implies that a CASE session had previously been established with a
161+
// valid provider
162+
if (!requestorCore->mProviderLocation.HasValue())
163+
{
164+
ChipLogError(SoftwareUpdate, "No provider location set");
165+
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, CHIP_ERROR_INCORRECT_STATE);
166+
return;
167+
}
168+
169+
// The Operational Node ID in the host field SHALL match the NodeID of the OTA Provider responding with the
170+
// QueryImageResponse
171+
if (update.nodeId != requestorCore->mProviderLocation.Value().providerNodeID)
172+
{
173+
ChipLogError(SoftwareUpdate,
174+
"The ImageURI provider node 0x" ChipLogFormatX64
175+
" does not match the QueryImageResponse provider node 0x" ChipLogFormatX64,
176+
ChipLogValueX64(update.nodeId), ChipLogValueX64(requestorCore->mProviderLocation.Value().providerNodeID));
177+
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, CHIP_ERROR_WRONG_NODE_ID);
178+
return;
179+
}
180+
159181
if (update.softwareVersion > requestorCore->mCurrentVersion)
160182
{
161183
ChipLogDetail(SoftwareUpdate, "Update available from version %" PRIu32 " to %" PRIu32, requestorCore->mCurrentVersion,

0 commit comments

Comments
 (0)