Skip to content

Commit

Permalink
Fix data corruption/mangling in DeviceCommissioner::SendOperationalCe…
Browse files Browse the repository at this point in the history
…rtificate (project-chip#7309)
  • Loading branch information
bluebin14 authored Jun 2, 2021
1 parent 51e396e commit bb8a6ef
Showing 1 changed file with 2 additions and 15 deletions.
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

0 comments on commit bb8a6ef

Please sign in to comment.