From 2692df35dbbcfc8e53cf3f17b1a604422a47202c Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Thu, 17 Oct 2024 17:35:42 +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. (#374) Co-authored-by: Chris Snow --- .../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 */