File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
libraries/cordio_stack/wsf/sources/port/baremetal
source/cordio/stack_adaptation Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ typedef struct wsfMsg_tag
5353/*************************************************************************************************/
5454void * WsfMsgDataAlloc (uint16_t len , uint8_t tailroom )
5555{
56+ /* check for overflow */
57+ if (len > UINT16_MAX - tailroom ) {
58+ return NULL ;
59+ }
5660 return WsfMsgAlloc (len + tailroom );
5761}
5862
@@ -69,6 +73,11 @@ void *WsfMsgAlloc(uint16_t len)
6973{
7074 wsfMsg_t * pMsg ;
7175
76+ /* check for overflow */
77+ if (len > UINT16_MAX - sizeof (wsfMsg_t )) {
78+ return NULL ;
79+ }
80+
7281 pMsg = WsfBufAlloc (len + sizeof (wsfMsg_t ));
7382
7483 /* hide header */
Original file line number Diff line number Diff line change @@ -204,6 +204,12 @@ void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len)
204204 }
205205
206206 /* allocate data buffer to hold entire packet */
207+ /* check that the length doesn't overflow */
208+ if (hdrLen > UINT16_MAX - dataLen )
209+ {
210+ stateRx = HCI_RX_STATE_IDLE ;
211+ return ;
212+ }
207213 if (pktIndRx == HCI_ACL_TYPE )
208214 {
209215 pPktRx = (uint8_t * )WsfMsgDataAlloc (hdrLen + dataLen , 0 );
You can’t perform that action at this time.
0 commit comments