Skip to content

Commit abe47b7

Browse files
joerchannashif
authored andcommitted
Bluetooth: controller: Check length field of adv and scan response data
Check the length field of the advertising and scan response data. Signed-off-by: Joakim Andersson <[email protected]>
1 parent 34918f1 commit abe47b7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

subsys/bluetooth/controller/ll_sw/ll_adv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ u8_t ll_adv_data_set(u8_t len, u8_t const *const data)
296296
struct pdu_adv *pdu;
297297
u8_t last;
298298

299+
if (len > PDU_AC_SIZE_MAX) {
300+
return BT_HCI_ERR_INVALID_PARAM;
301+
}
302+
299303
/* Dont update data if directed or extended advertising. */
300304
radio_adv_data = radio_adv_data_get();
301305
prev = (struct pdu_adv *)&radio_adv_data->data[radio_adv_data->last][0];
@@ -352,6 +356,10 @@ u8_t ll_adv_scan_rsp_set(u8_t len, u8_t const *const data)
352356
struct pdu_adv *pdu;
353357
u8_t last;
354358

359+
if (len > PDU_AC_SIZE_MAX) {
360+
return BT_HCI_ERR_INVALID_PARAM;
361+
}
362+
355363
/* use the last index in double buffer, */
356364
radio_scan_data = radio_scan_data_get();
357365
if (radio_scan_data->first == radio_scan_data->last) {

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ u8_t ll_adv_data_set(u8_t len, u8_t const *const data)
331331
struct pdu_adv *pdu;
332332
u8_t idx;
333333

334+
if (len > PDU_AC_SIZE_MAX) {
335+
return BT_HCI_ERR_INVALID_PARAM;
336+
}
337+
334338
adv = ull_adv_set_get(handle);
335339
if (!adv) {
336340
return BT_HCI_ERR_CMD_DISALLOWED;
@@ -382,6 +386,10 @@ u8_t ll_adv_scan_rsp_set(u8_t len, u8_t const *const data)
382386
struct pdu_adv *pdu;
383387
u8_t idx;
384388

389+
if (len > PDU_AC_SIZE_MAX) {
390+
return BT_HCI_ERR_INVALID_PARAM;
391+
}
392+
385393
adv = ull_adv_set_get(handle);
386394
if (!adv) {
387395
return BT_HCI_ERR_CMD_DISALLOWED;

0 commit comments

Comments
 (0)