Skip to content

Commit

Permalink
Addressed review comments (#14400)
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 authored and pull[bot] committed Sep 1, 2023
1 parent 58408ff commit 1588372
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/clusters/ota-requestor/OTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ void OTARequestor::OnQueryImageResponse(void * context, const QueryImageResponse
ChipLogDetail(SoftwareUpdate, "Update available from %" PRIu32 " to %" PRIu32 " version",
requestorCore->mCurrentVersion, update.softwareVersion);
MutableByteSpan updateToken(requestorCore->mUpdateTokenBuffer);
CopySpanToMutableSpan(update.updateToken, updateToken);
// This function copies the bytespan to mutablebytespan only if size of mutablebytespan buffer is greater or equal to
// bytespan otherwise we are copying data upto available size.
err = CopySpanToMutableSpan(update.updateToken, updateToken);
if (err == CHIP_ERROR_BUFFER_TOO_SMALL)
{
memset(updateToken.data(), 0, updateToken.size());
requestorCore->GenerateUpdateToken();
}
requestorCore->mTargetVersion = update.softwareVersion;
requestorCore->mUpdateToken = updateToken;

Expand Down Expand Up @@ -585,8 +592,6 @@ CHIP_ERROR OTARequestor::ExtractUpdateDescription(const QueryImageResponseDecoda
update.softwareVersion = response.softwareVersion.Value();

VerifyOrReturnError(response.updateToken.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(response.updateToken.Value().size() >= 8 && response.updateToken.Value().size() <= 32,
CHIP_ERROR_INVALID_ARGUMENT);
update.updateToken = response.updateToken.Value();

update.userConsentNeeded = response.userConsentNeeded.ValueOr(false);
Expand Down

0 comments on commit 1588372

Please sign in to comment.