@@ -556,8 +556,7 @@ static int hci_set_adv_ext_complete(struct bt_le_ext_adv *adv, uint16_t hci_op,
556
556
total_data_len = BT_GAP_ADV_MAX_ADV_DATA_LEN ;
557
557
}
558
558
559
- cmd_size = total_data_len +
560
- offsetof(struct bt_hci_cp_le_set_ext_adv_data , data );
559
+ cmd_size = sizeof (* set_data ) + total_data_len ;
561
560
562
561
buf = bt_hci_cmd_create (hci_op , cmd_size );
563
562
if (!buf ) {
@@ -596,9 +595,8 @@ static int hci_set_adv_ext_fragmented(struct bt_le_ext_adv *adv, uint16_t hci_op
596
595
while (!ad_stream_is_empty (& stream )) {
597
596
struct bt_hci_cp_le_set_ext_adv_data * set_data ;
598
597
struct net_buf * buf ;
599
- size_t data_len = MIN (sizeof (set_data -> data ), stream .remaining_size );
600
- const size_t cmd_size = data_len +
601
- offsetof(struct bt_hci_cp_le_set_ext_adv_data , data );
598
+ const size_t data_len = MIN (BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN , stream .remaining_size );
599
+ const size_t cmd_size = sizeof (* set_data ) + data_len ;
602
600
int err ;
603
601
604
602
buf = bt_hci_cmd_create (hci_op , cmd_size );
@@ -610,7 +608,7 @@ static int hci_set_adv_ext_fragmented(struct bt_le_ext_adv *adv, uint16_t hci_op
610
608
611
609
set_data -> handle = adv -> handle ;
612
610
set_data -> frag_pref = BT_HCI_LE_EXT_ADV_FRAG_ENABLED ;
613
- set_data -> len = ad_stream_read (& stream , set_data -> data , sizeof ( set_data -> data ) );
611
+ set_data -> len = ad_stream_read (& stream , set_data -> data , data_len );
614
612
615
613
if (is_first_iteration && ad_stream_is_empty (& stream )) {
616
614
set_data -> op = BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA ;
@@ -705,9 +703,8 @@ static int hci_set_per_adv_data(const struct bt_le_ext_adv *adv,
705
703
while (!ad_stream_is_empty (& stream )) {
706
704
struct bt_hci_cp_le_set_per_adv_data * set_data ;
707
705
struct net_buf * buf ;
708
- size_t data_len = MIN (sizeof (set_data -> data ), stream .remaining_size );
709
- const size_t cmd_size = data_len +
710
- offsetof(struct bt_hci_cp_le_set_ext_adv_data , data );
706
+ const size_t data_len = MIN (BT_HCI_LE_PER_ADV_FRAG_MAX_LEN , stream .remaining_size );
707
+ const size_t cmd_size = sizeof (* set_data ) + data_len ;
711
708
int err ;
712
709
713
710
buf = bt_hci_cmd_create (BT_HCI_OP_LE_SET_PER_ADV_DATA , cmd_size );
@@ -719,7 +716,7 @@ static int hci_set_per_adv_data(const struct bt_le_ext_adv *adv,
719
716
(void )memset (set_data , 0 , cmd_size );
720
717
721
718
set_data -> handle = adv -> handle ;
722
- set_data -> len = ad_stream_read (& stream , set_data -> data , sizeof ( set_data -> data ) );
719
+ set_data -> len = ad_stream_read (& stream , set_data -> data , data_len );
723
720
724
721
if (is_first_iteration && ad_stream_is_empty (& stream )) {
725
722
set_data -> op = BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA ;
0 commit comments