Skip to content

Commit

Permalink
[OTA] Validate various error ImageURI cases (#17223)
Browse files Browse the repository at this point in the history
  • Loading branch information
carol-apple authored and pull[bot] committed Nov 6, 2023
1 parent 93cc959 commit 5df3bdf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,32 @@ void DefaultOTARequestor::OnQueryImageResponse(void * context, const QueryImageR

if (err != CHIP_NO_ERROR)
{
ChipLogError(SoftwareUpdate, "QueryImageResponse contains invalid fields: %" CHIP_ERROR_FORMAT, err.Format());
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, err);
return;
}

// This should never happen since receiving a response implies that a CASE session had previously been established with a
// valid provider
if (!requestorCore->mProviderLocation.HasValue())
{
ChipLogError(SoftwareUpdate, "No provider location set");
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, CHIP_ERROR_INCORRECT_STATE);
return;
}

// The Operational Node ID in the host field SHALL match the NodeID of the OTA Provider responding with the
// QueryImageResponse
if (update.nodeId != requestorCore->mProviderLocation.Value().providerNodeID)
{
ChipLogError(SoftwareUpdate,
"The ImageURI provider node 0x" ChipLogFormatX64
" does not match the QueryImageResponse provider node 0x" ChipLogFormatX64,
ChipLogValueX64(update.nodeId), ChipLogValueX64(requestorCore->mProviderLocation.Value().providerNodeID));
requestorCore->RecordErrorUpdateState(UpdateFailureState::kQuerying, CHIP_ERROR_WRONG_NODE_ID);
return;
}

if (update.softwareVersion > requestorCore->mCurrentVersion)
{
ChipLogDetail(SoftwareUpdate, "Update available from version %" PRIu32 " to %" PRIu32, requestorCore->mCurrentVersion,
Expand Down

0 comments on commit 5df3bdf

Please sign in to comment.