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 data corruption/mangling in DeviceCommissioner::SendOperationalCertificate #7309

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all 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
17 changes: 2 additions & 15 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,21 +1218,8 @@ CHIP_ERROR DeviceCommissioner::SendOperationalCertificate(Device * device, const
Callback::Cancelable * successCallback = mOpCertResponseCallback.Cancel();
Callback::Cancelable * failureCallback = mOnCertFailureCallback.Cancel();

// TODO - Update ZAP to use 16 bit length for OCTET_STRING. This is a temporary hack, as OCTET_STRING only supports 8 bit
// strings.
if (opCertBuf.size() >= UINT8_MAX)
{
ByteSpan tempCertFragment(&opCertBuf.data()[UINT8_MAX], opCertBuf.size() - UINT8_MAX);
ByteSpan opCertFragment(opCertBuf.data(), UINT8_MAX);

ReturnErrorOnFailure(cluster.AddOpCert(successCallback, failureCallback, opCertFragment, tempCertFragment,
ByteSpan(nullptr, 0), mLocalDeviceId, 0));
}
else
{
ReturnErrorOnFailure(cluster.AddOpCert(successCallback, failureCallback, opCertBuf, ByteSpan(nullptr, 0),
ByteSpan(nullptr, 0), mLocalDeviceId, 0));
}
ReturnErrorOnFailure(
cluster.AddOpCert(successCallback, failureCallback, opCertBuf, icaCertBuf, ByteSpan(nullptr, 0), mLocalDeviceId, 0));

ChipLogProgress(Controller, "Sent operational certificate to the device");

Expand Down