Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordio BLE: Fix integer overflows (CVE-2024-48983) #388

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ typedef struct wsfMsg_tag
/*************************************************************************************************/
void *WsfMsgDataAlloc(uint16_t len, uint8_t tailroom)
{
/* check for overflow */
if (len > UINT16_MAX - tailroom) {
return NULL;
}
return WsfMsgAlloc(len + tailroom);
}

Expand All @@ -69,6 +73,11 @@ void *WsfMsgAlloc(uint16_t len)
{
wsfMsg_t *pMsg;

/* check for overflow */
if (len > UINT16_MAX - sizeof(wsfMsg_t)) {
return NULL;
}

pMsg = WsfBufAlloc(len + sizeof(wsfMsg_t));

/* hide header */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ void hciTrSerialRxIncoming(uint8_t *pBuf, uint8_t len)
}

/* allocate data buffer to hold entire packet */
/* check that the length doesn't overflow */
if (hdrLen > UINT16_MAX - dataLen)
{
stateRx = HCI_RX_STATE_IDLE;
return;
}
if (pktIndRx == HCI_ACL_TYPE)
{
pPktRx = (uint8_t*)WsfMsgDataAlloc(hdrLen + dataLen, 0);
Expand Down