From 0b8cb903dc23d7a6d91b1a479c70f4d4fb270934 Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Wed, 16 Oct 2024 11:28:57 +0100 Subject: [PATCH] Set the stateRx variable to HCI_RX_STATE_IDLE when an invalid HCI packet type is detected, to prevent overflow in the hdrRx buffer. --- .../source/cordio/stack_adaptation/hci_tr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c index 9245499fa19..7663276ec5b 100644 --- a/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c +++ b/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c @@ -170,9 +170,18 @@ void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len) hdrLen = HCI_EVT_HDR_LEN; break; default: - /* invalid packet type */ + /** + * invalid packet type + * + * fix: Simply employing WSF_ASSERT in the event of + * an "invalid packet type" is not reasonable. + * Instead, it is advisable to discard this data packet, + * exit the packet processing function, + * and adjust the stateRx back to HCI_RX_STATE_IDLE. + */ + stateRx = HCI_RX_STATE_IDLE; WSF_ASSERT(0); - break; + return; } /* see if entire header has been read */