Skip to content

Commit ecfc6e1

Browse files
ekleezgMaureenHelm
authored andcommitted
Bluetooth: Host: Add missing buffer length check
Modified to check the length of the remaining data in buffer before processing the next report. The length check is missing in the cont routine. Signed-off-by: Eunkyu Lee <[email protected]> (cherry picked from commit e491f22)
1 parent 6567d6e commit ecfc6e1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

subsys/bluetooth/host/scan.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,24 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf)
602602
is_report_complete = data_status == BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE;
603603
more_to_come = data_status == BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL;
604604

605+
if (evt->length > buf->len) {
606+
LOG_WRN("Adv report corrupted (wants %u out of %u)", evt->length, buf->len);
607+
608+
net_buf_reset(buf);
609+
610+
if (evt_type & BT_HCI_LE_ADV_EVT_TYPE_LEGACY) {
611+
return;
612+
}
613+
614+
/* Start discarding irrespective of the `more_to_come` flag. We
615+
* assume we may have lost a partial adv report in the truncated
616+
* data.
617+
*/
618+
reassembling_advertiser.state = FRAG_ADV_DISCARDING;
619+
620+
return;
621+
}
622+
605623
if (evt_type & BT_HCI_LE_ADV_EVT_TYPE_LEGACY) {
606624
/* Legacy advertising reports are complete.
607625
* Create event immediately.

0 commit comments

Comments
 (0)