Skip to content

Commit 64990df

Browse files
wqx6austina-csa
authored andcommitted
ESP32: Fix data copy in BLE HandleRxNotify() (project-chip#34204)
1 parent ea6e910 commit 64990df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1749,10 +1749,12 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg)
17491749
#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER
17501750
CHIP_ERROR BLEManagerImpl::HandleRXNotify(struct ble_gap_event * ble_event)
17511751
{
1752-
uint8_t * data = OS_MBUF_DATA(ble_event->notify_rx.om, uint8_t *);
17531752
size_t dataLen = OS_MBUF_PKTLEN(ble_event->notify_rx.om);
1754-
System::PacketBufferHandle buf = System::PacketBufferHandle::NewWithData(data, dataLen);
1753+
System::PacketBufferHandle buf = System::PacketBufferHandle::New(dataLen, 0);
17551754
VerifyOrReturnError(!buf.IsNull(), CHIP_ERROR_NO_MEMORY);
1755+
VerifyOrExit(buf->AvailableDataLength() >= data_len, err = CHIP_ERROR_BUFFER_TOO_SMALL);
1756+
ble_hs_mbuf_to_flat(ble_event->notify_rx.om, buf->Start(), data_len, NULL);
1757+
buf->SetDataLength(data_len);
17561758

17571759
ChipLogDetail(DeviceLayer, "Indication received, conn = %d", ble_event->notify_rx.conn_handle);
17581760

0 commit comments

Comments
 (0)