Skip to content

Commit a19af1a

Browse files
committed
Address review comments
1 parent 4294fe2 commit a19af1a

24 files changed

+110
-75
lines changed

src/ble/BtpEngine.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <lib/support/BitFlags.h>
3535
#include <lib/support/BufferReader.h>
3636
#include <lib/support/CodeUtils.h>
37+
#include <lib/support/SafeInt.h>
3738
#include <lib/support/logging/CHIPLogging.h>
3839
#include <system/SystemPacketBuffer.h>
3940

@@ -346,6 +347,7 @@ CHIP_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle &&
346347
if (rx_flags.Has(HeaderFlags::kEndMessage))
347348
{
348349
// Trim remainder, if any, of the received packet buffer based on sender-specified length of reassembled message.
350+
VerifyOrExit(CanCastTo<uint16_t>(mRxBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
349351
int padding = static_cast<uint16_t>(mRxBuf->DataLength()) - mRxLength;
350352

351353
if (padding > 0)
@@ -426,8 +428,9 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s
426428
return false;
427429
}
428430

429-
mTxBuf = std::move(data);
430-
mTxState = kState_InProgress;
431+
mTxBuf = std::move(data);
432+
mTxState = kState_InProgress;
433+
VerifyOrReturnError(CanCastTo<uint16_t>(mTxBuf->DataLength()), false);
431434
mTxLength = static_cast<uint16_t>(mTxBuf->DataLength());
432435

433436
ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send whole message:");

src/ble/tests/TestBtpEngine.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedOnePacket)
6767
};
6868

6969
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
70-
EXPECT_EQ(packet0->DataLength(), 5);
70+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
7171

7272
SequenceNumber_t receivedAck;
7373
bool didReceiveAck;
@@ -81,15 +81,15 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedTwoPacket)
8181
constexpr uint8_t packetData1[] = { to_underlying(BtpEngine::HeaderFlags::kEndMessage), 0x02, 0xff };
8282

8383
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
84-
EXPECT_EQ(packet0->DataLength(), 5);
84+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
8585

8686
SequenceNumber_t receivedAck;
8787
bool didReceiveAck;
8888
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet0), receivedAck, didReceiveAck), CHIP_NO_ERROR);
8989
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
9090

9191
auto packet1 = System::PacketBufferHandle::NewWithData(packetData1, sizeof(packetData1));
92-
EXPECT_EQ(packet1->DataLength(), 3);
92+
EXPECT_EQ(packet1->DataLength(), static_cast<size_t>(3));
9393

9494
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet1), receivedAck, didReceiveAck), CHIP_NO_ERROR);
9595
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_Complete);
@@ -102,21 +102,21 @@ TEST_F(TestBtpEngine, HandleCharacteristicReceivedThreePacket)
102102
constexpr uint8_t packetData2[] = { to_underlying(BtpEngine::HeaderFlags::kEndMessage), 0x03, 0xff };
103103

104104
auto packet0 = System::PacketBufferHandle::NewWithData(packetData0, sizeof(packetData0));
105-
EXPECT_EQ(packet0->DataLength(), 5);
105+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
106106

107107
SequenceNumber_t receivedAck;
108108
bool didReceiveAck;
109109
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet0), receivedAck, didReceiveAck), CHIP_NO_ERROR);
110110
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
111111

112112
auto packet1 = System::PacketBufferHandle::NewWithData(packetData1, sizeof(packetData1));
113-
EXPECT_EQ(packet1->DataLength(), 3);
113+
EXPECT_EQ(packet1->DataLength(), static_cast<size_t>(3));
114114

115115
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet1), receivedAck, didReceiveAck), CHIP_NO_ERROR);
116116
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_InProgress);
117117

118118
auto packet2 = System::PacketBufferHandle::NewWithData(packetData2, sizeof(packetData2));
119-
EXPECT_EQ(packet2->DataLength(), 3);
119+
EXPECT_EQ(packet2->DataLength(), static_cast<size_t>(3));
120120

121121
EXPECT_EQ(mBtpEngine.HandleCharacteristicReceived(std::move(packet2), receivedAck, didReceiveAck), CHIP_NO_ERROR);
122122
EXPECT_EQ(mBtpEngine.RxState(), BtpEngine::kState_Complete);
@@ -133,7 +133,7 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendOnePacket)
133133

134134
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
135135
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
136-
EXPECT_EQ(packet0->DataLength(), 5);
136+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(5));
137137
}
138138

139139
TEST_F(TestBtpEngine, HandleCharacteristicSendTwoPacket)
@@ -147,11 +147,11 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendTwoPacket)
147147

148148
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
149149
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
150-
EXPECT_EQ(packet0->DataLength(), 20);
150+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
151151

152152
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
153153
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
154-
EXPECT_EQ(packet0->DataLength(), 16);
154+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(16));
155155
}
156156

157157
// Send 40-byte payload.
@@ -169,15 +169,15 @@ TEST_F(TestBtpEngine, HandleCharacteristicSendThreePacket)
169169

170170
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(packet0.Retain(), false));
171171
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
172-
EXPECT_EQ(packet0->DataLength(), 20);
172+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
173173

174174
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
175175
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_InProgress);
176-
EXPECT_EQ(packet0->DataLength(), 20);
176+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(20));
177177

178178
EXPECT_TRUE(mBtpEngine.HandleCharacteristicSend(nullptr, false));
179179
EXPECT_EQ(mBtpEngine.TxState(), BtpEngine::kState_Complete);
180-
EXPECT_EQ(packet0->DataLength(), 8);
180+
EXPECT_EQ(packet0->DataLength(), static_cast<size_t>(8));
181181
}
182182

183183
} // namespace

src/inet/TCPEndPointImplLwIP.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ CHIP_ERROR TCPEndPointImplLwIP::DriveSendingImpl()
350350
do
351351
{
352352
VerifyOrDie(!startOfUnsent.buffer.IsNull());
353-
353+
VerifyOrDie(CanCastTo<uint16_t>(startOfUnsent.buffer->DataLength()));
354354
uint16_t bufDataLen = static_cast<uint16_t>(startOfUnsent.buffer->DataLength());
355355

356356
// Get a pointer to the start of unsent data within the first buffer on the unsent queue.
@@ -508,7 +508,7 @@ CHIP_ERROR TCPEndPointImplLwIP::AckReceive(size_t len)
508508
VerifyOrReturnError(IsConnected(), CHIP_ERROR_INCORRECT_STATE);
509509
CHIP_ERROR res = CHIP_NO_ERROR;
510510

511-
VerifyOrReturnError(len < UINT16_MAX, CHIP_ERROR_INVALID_ARGUMENT);
511+
VerifyOrReturnError(CanCastTo<uint16_t>(len), CHIP_ERROR_INVALID_ARGUMENT);
512512

513513
// Lock LwIP stack
514514
LOCK_TCPIP_CORE();
@@ -572,6 +572,7 @@ TCPEndPointImplLwIP::BufferOffset TCPEndPointImplLwIP::FindStartOfUnsent()
572572
while (leftToSkip > 0)
573573
{
574574
VerifyOrDie(!startOfUnsent.buffer.IsNull());
575+
VerifyOrDie(CanCastTo<uint16_t>(startOfUnsent.buffer->DataLength()));
575576
uint16_t bufDataLen = static_cast<uint16_t>(startOfUnsent.buffer->DataLength());
576577
if (leftToSkip >= bufDataLen)
577578
{

src/inet/TCPEndPointImplSockets.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ CHIP_ERROR TCPEndPointImplSockets::DriveSendingImpl()
483483

484484
while (!mSendQueue.IsNull())
485485
{
486-
uint32_t bufLen = static_cast<uint32_t>(mSendQueue->DataLength());
486+
size_t bufLen = mSendQueue->DataLength();
487487

488488
ssize_t lenSentRaw = send(mSocket, mSendQueue->Start(), bufLen, sendFlags);
489489

@@ -496,14 +496,13 @@ CHIP_ERROR TCPEndPointImplSockets::DriveSendingImpl()
496496
break;
497497
}
498498

499-
if (lenSentRaw < 0 || bufLen < static_cast<uint32_t>(lenSentRaw))
499+
if (lenSentRaw < 0 || bufLen < static_cast<size_t>(lenSentRaw))
500500
{
501501
err = CHIP_ERROR_INCORRECT_STATE;
502502
break;
503503
}
504504

505-
// Cast is safe because bufLen is uint32_t.
506-
uint32_t lenSent = static_cast<uint32_t>(lenSentRaw);
505+
size_t lenSent = static_cast<size_t>(lenSentRaw);
507506

508507
// Mark the connection as being active.
509508
MarkActive();

src/inet/UDPEndPointImplOpenThread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ CHIP_ERROR UDPEndPointImplOT::SendMsgImpl(const IPPacketInfo * aPktInfo, System:
225225
otMessageInfo messageInfo;
226226

227227
// For now the entire message must fit within a single buffer.
228-
VerifyOrReturnError(!msg->HasChainedBuffer(), CHIP_ERROR_MESSAGE_TOO_LONG);
228+
VerifyOrReturnError(!msg->HasChainedBuffer() && msg->DataLength() <= UINT16_MAX, CHIP_ERROR_MESSAGE_TOO_LONG);
229229

230230
memset(&messageInfo, 0, sizeof(messageInfo));
231231

src/inet/UDPEndPointImplSockets.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void UDPEndPointImplSockets::HandlePendingIO(System::SocketEvents events)
610610

611611
ssize_t rcvLen = recvmsg(mSocket, &msgHeader, MSG_DONTWAIT);
612612

613-
if (rcvLen < 0)
613+
if (rcvLen == -1)
614614
{
615615
lStatus = CHIP_ERROR_POSIX(errno);
616616
}

src/inet/tests/TestInetLayerCommon.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <inet/IPPacketInfo.h>
3737
#include <lib/support/CodeUtils.h>
38+
#include <lib/support/SafeInt.h>
3839

3940
#include "TestInetCommon.h"
4041

@@ -259,6 +260,7 @@ static bool HandleDataReceived(const PacketBufferHandle & aBuffer, TransferStats
259260
// If we are accumulating stats by packet rather than by size,
260261
// then increment by one (1) rather than the total buffer length.
261262

263+
VerifyOrReturnError(CanCastTo<uint32_t>(lTotalDataLength), false);
262264
aStats.mReceive.mActual += ((aStatsByPacket) ? 1 : static_cast<uint32_t>(lTotalDataLength));
263265

264266
return true;

src/lib/core/tests/TestTLV.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ void TestDupBytes(TLVReader & reader, Tag tag, const uint8_t * expectedVal, uint
269269
chip::Platform::MemoryFree(val);
270270
}
271271

272-
void TestBufferContents(const System::PacketBufferHandle & buffer, const uint8_t * expectedVal, uint32_t expectedLen)
272+
void TestBufferContents(const System::PacketBufferHandle & buffer, const uint8_t * expectedVal, size_t expectedLen)
273273
{
274274
System::PacketBufferHandle buf = buffer.Retain();
275275
while (!buf.IsNull())
276276
{
277-
uint32_t len = static_cast<uint32_t>(buf->DataLength());
277+
size_t len = buf->DataLength();
278278
EXPECT_LE(len, expectedLen);
279279

280280
EXPECT_EQ(memcmp(buf->Start(), expectedVal, len), 0);

src/messaging/tests/echo/echo_requester.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void HandleEchoResponseReceived(chip::Messaging::ExchangeContext * ec, chip::Sys
183183

184184
gEchoRespCount++;
185185

186-
printf("Echo Response: %" PRIu64 "/%" PRIu64 "(%.2f%%) len=%u time=%.3fs\n", gEchoRespCount, gEchoCount,
186+
printf("Echo Response: %" PRIu64 "/%" PRIu64 "(%.2f%%) len=%" PRIu32 "time=%.3fs\n", gEchoRespCount, gEchoCount,
187187
static_cast<double>(gEchoRespCount) * 100 / static_cast<double>(gEchoCount),
188188
static_cast<uint32_t>(payload->DataLength()),
189189
static_cast<double>(chip::System::Clock::Milliseconds32(transitTime).count()) / 1000);

src/messaging/tests/echo/echo_responder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ chip::SessionHolder gSession;
4949
// Callback handler when a CHIP EchoRequest is received.
5050
void HandleEchoRequestReceived(chip::Messaging::ExchangeContext * ec, chip::System::PacketBufferHandle && payload)
5151
{
52-
printf("Echo Request, len=%u ... sending response.\n", static_cast<uint32_t>(payload->DataLength()));
52+
printf("Echo Request, len=%" PRIu32 "... sending response.\n", static_cast<uint32_t>(payload->DataLength()));
5353
}
5454

5555
} // namespace

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <ble/Ble.h>
3535
#endif
3636
#include <lib/support/CodeUtils.h>
37+
#include <lib/support/SafeInt.h>
3738
#include <lib/support/logging/CHIPLogging.h>
3839
#include <platform/CommissionableDataProvider.h>
3940
#include <platform/DeviceInstanceInfoProvider.h>
@@ -611,6 +612,10 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
611612

612613
ESP_LOGD(TAG, "Sending indication for CHIPoBLE TX characteristic (con %u, len %u)", conId, data->DataLength());
613614

615+
// For BLE, the buffer is capped at UINT16_MAX. Nevertheless, have a verify
616+
// check before the cast to uint16_t.
617+
VerifyOrExit(CanCastTo<uint16_t>(data->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
618+
614619
om = ble_hs_mbuf_from_flat(data->Start(), static_cast<uint16_t>(data->DataLength()));
615620
if (om == NULL)
616621
{

src/platform/Zephyr/BLEManagerImpl.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <ble/Ble.h>
3131
#include <lib/support/CHIPMemString.h>
3232
#include <lib/support/CodeUtils.h>
33+
#include <lib/support/SafeInt.h>
3334
#include <lib/support/logging/CHIPLogging.h>
3435
#include <platform/DeviceInstanceInfoProvider.h>
3536
#include <platform/internal/BLEManager.h>
@@ -707,7 +708,8 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
707708
params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex];
708709
params->func = HandleTXIndicated;
709710
params->data = pBuf->Start();
710-
params->len = static_cast<uint16_t>(pBuf->DataLength());
711+
VerifyOrExit(CanCastTo<uint16_t>(pBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
712+
params->len = static_cast<uint16_t>(pBuf->DataLength());
711713

712714
status = bt_gatt_indicate(conId, params);
713715
VerifyOrExit(status == 0, err = MapErrorZephyr(status));
@@ -885,6 +887,8 @@ ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gat
885887
return 0;
886888
}
887889

890+
// For BLE, the max payload size is limited to UINT16_MAX since the length
891+
// field is 2 bytes long. So, the cast to uint16_t should be fine.
888892
return bt_gatt_attr_read(conId, attr, buf, len, offset, sInstance.c3CharDataBufferHandle->Start(),
889893
static_cast<uint16_t>(sInstance.c3CharDataBufferHandle->DataLength()));
890894
}

src/platform/android/BLEManagerImpl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::Ch
384384
err = JniReferences::GetInstance().N2J_ByteArray(env, static_cast<const uint8_t *>(charId->bytes), 16, charIdObj);
385385
SuccessOrExit(err);
386386

387+
VerifyOrExit(CanCastTo<uint16_t>(pBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
387388
err = JniReferences::GetInstance().N2J_ByteArray(env, pBuf->Start(), static_cast<uint16_t>(pBuf->DataLength()),
388389
characteristicDataObj);
389390
SuccessOrExit(err);

src/platform/bouffalolab/common/BLEManagerImpl.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <ble/Ble.h>
2525
#include <lib/support/CHIPMemString.h>
26+
#include <lib/support/SafeInt.h>
2627
#include <platform/DeviceInstanceInfoProvider.h>
2728
#include <platform/internal/BLEManager.h>
2829
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
@@ -669,7 +670,10 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
669670
params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex];
670671
params->func = HandleTXIndicated;
671672
params->data = pBuf->Start();
672-
params->len = static_cast<uint16_t>(pBuf->DataLength());
673+
// For BLE, the buffer is capped at UINT16_MAX. Nevertheless, have a verify
674+
// check before the cast to uint16_t.
675+
VerifyOrExit(CanCastTo<uint16_t>(pBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
676+
params->len = static_cast<uint16_t>(pBuf->DataLength());
673677

674678
status = bt_gatt_indicate(conId, params);
675679
VerifyOrExit(status == 0, err = MapErrorZephyr(status));
@@ -848,6 +852,8 @@ ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gat
848852
return 0;
849853
}
850854

855+
// For BLE, the max payload size is limited to UINT16_MAX since the length
856+
// field is 2 bytes long. So, the cast to uint16_t should be fine.
851857
return bt_gatt_attr_read(conId, attr, buf, len, offset, sInstance.c3CharDataBufferHandle->Start(),
852858
static_cast<uint16_t>(sInstance.c3CharDataBufferHandle->DataLength()));
853859
}

src/platform/mbed/BLEManagerImpl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <ble/Ble.h>
3434
#include <lib/support/CodeUtils.h>
35+
#include <lib/support/SafeInt.h>
3536
#include <lib/support/logging/CHIPLogging.h>
3637
#include <platform/CommissionableDataProvider.h>
3738
#include <platform/internal/BLEManager.h>
@@ -984,6 +985,9 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
984985
ble::GattServer & gatt_server = ble::BLE::Instance().gattServer();
985986
ble::attribute_handle_t att_handle;
986987

988+
// For BLE, the buffer is capped at UINT16_MAX.
989+
VerifyOrExit(CanCastTo<uint16_t>(pBuf->DataLength()), err = CHIP_ERROR_MESSAGE_TOO_LONG);
990+
987991
// No need to do anything fancy here. Only 3 handles are used in this impl.
988992
if (UUIDsMatch(charId, &ChipUUID_CHIPoBLEChar_TX))
989993
{

src/protocols/secure_channel/CASESession.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,8 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg)
15791579
TLV::TLVReader decryptedDataTlvReader;
15801580
TLV::TLVType containerType = TLV::kTLVType_Structure;
15811581

1582-
const uint8_t * buf = msg->Start();
1583-
const uint32_t bufLen = static_cast<uint32_t>(msg->DataLength());
1582+
const uint8_t * buf = msg->Start();
1583+
const size_t bufLen = msg->DataLength();
15841584

15851585
constexpr size_t kCaseOverheadForFutureTbeData = 128;
15861586

src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void UserDirectedCommissioningClient::OnMessageReceived(const Transport::PeerAdd
255255
PayloadHeader payloadHeader;
256256
ReturnOnFailure(payloadHeader.DecodeAndConsume(msg));
257257

258-
ChipLogProgress(AppServer, "CommissionerDeclaration DataLength()=%u", static_cast<uint16_t>(msg->DataLength()));
258+
ChipLogProgress(AppServer, "CommissionerDeclaration DataLength()=%" PRIu32, static_cast<uint32_t>(msg->DataLength()));
259259

260260
uint8_t udcPayload[IdentificationDeclaration::kUdcTLVDataMaxBytes];
261261
size_t udcPayloadLength = std::min<size_t>(msg->DataLength(), sizeof(udcPayload));

src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void UserDirectedCommissioningServer::OnMessageReceived(const Transport::PeerAdd
5252
PayloadHeader payloadHeader;
5353
ReturnOnFailure(payloadHeader.DecodeAndConsume(msg));
5454

55-
ChipLogProgress(AppServer, "IdentityDeclaration DataLength()=%u", static_cast<uint16_t>(msg->DataLength()));
55+
ChipLogProgress(AppServer, "IdentityDeclaration DataLength()=%" PRIu32, static_cast<uint32_t>(msg->DataLength()));
5656

5757
uint8_t udcPayload[IdentificationDeclaration::kUdcTLVDataMaxBytes];
5858
size_t udcPayloadLength = std::min<size_t>(msg->DataLength(), sizeof(udcPayload));

0 commit comments

Comments
 (0)