Skip to content

Commit 784417f

Browse files
authored
Cordio BLE: fix OOB read in event processing (#387)
1 parent 8576b04 commit 784417f

File tree

1 file changed

+11
-0
lines changed
  • connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip

1 file changed

+11
-0
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c

+11
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,11 @@ static void hciEvtProcessLeExtAdvReport(uint8_t *p, uint8_t len)
13311331
while (i-- > 0)
13321332
{
13331333
ptr += HCI_EXT_ADV_RPT_DATA_LEN_OFFSET;
1334+
// discard event if it doesn't contain enough data
1335+
if (ptr >= p + len)
1336+
{
1337+
return;
1338+
}
13341339
BSTREAM_TO_UINT8(dataLen, ptr);
13351340
ptr += dataLen;
13361341

@@ -1342,6 +1347,12 @@ static void hciEvtProcessLeExtAdvReport(uint8_t *p, uint8_t len)
13421347
}
13431348
}
13441349

1350+
// finally check that the last report is fully contained within the event
1351+
if (ptr > p + len)
1352+
{
1353+
return;
1354+
}
1355+
13451356
/* allocate temp buffer that can hold max length ext adv/scan rsp data */
13461357
if ((pMsg = WsfBufAlloc(sizeof(hciLeExtAdvReportEvt_t) + maxLen)) != NULL)
13471358
{

0 commit comments

Comments
 (0)