Skip to content

fix the potential overflow problem of leAdvertisingReport->eirData #220

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

Closed
4 changes: 4 additions & 0 deletions src/utility/HCI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,10 @@ void HCIClass::handleEventPkt(uint8_t /*plen*/, uint8_t pdata[])
uint8_t eirData[31];
} *leAdvertisingReport = (EvtLeAdvertisingReport*)&pdata[sizeof(HCIEventHdr) + sizeof(LeMetaEventHeader)];

if(leAdvertisingReport->eirLength > sizeof(leAdvertisingReport->eirData)){
return ;
}

if (leAdvertisingReport->status == 0x01) {
// last byte is RSSI
int8_t rssi = leAdvertisingReport->eirData[leAdvertisingReport->eirLength];
Expand Down