Skip to content

Commit 417647f

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix extended header data be zero-length array
Fix the definiion of Common Extended Payload Format data field in the PDU definitions to be zero-length array, because PDU size are configurable and to avoid allocations being made using these PDU structs. Corrected the extended scan response length check code to use the correct define instead. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 14b369e commit 417647f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

subsys/bluetooth/controller/ll_sw/pdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ struct pdu_adv_com_ext_adv {
279279
#endif
280280
union {
281281
struct pdu_adv_ext_hdr ext_hdr;
282-
uint8_t ext_hdr_adv_data[254];
282+
uint8_t ext_hdr_adv_data[0];
283283
};
284284
} __packed;
285285

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ uint8_t ll_adv_aux_sr_data_set(uint8_t handle, uint8_t op, uint8_t frag_pref, ui
304304
/* Check if data will fit in remaining space */
305305
/* TODO: need aux_chain_ind support */
306306
ext_hdr_len = sr_dptr - &sr_com_hdr->ext_hdr_adv_data[0];
307-
if (sizeof(sr_com_hdr->ext_hdr_adv_data) -
308-
sr_com_hdr->ext_hdr_len < len) {
307+
if ((PDU_AC_EXT_HEADER_SIZE_MIN + ext_hdr_len + len) >
308+
PDU_AC_PAYLOAD_SIZE_MAX) {
309309
return BT_HCI_ERR_PACKET_TOO_LONG;
310310
}
311311

@@ -749,6 +749,7 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv,
749749
sec_len += ad_len;
750750

751751
/* Check AdvData overflow */
752+
/* TODO: need aux_chain_ind support */
752753
if (sec_len > PDU_AC_PAYLOAD_SIZE_MAX) {
753754
/* FIXME: release allocations */
754755
return BT_HCI_ERR_PACKET_TOO_LONG;

0 commit comments

Comments
 (0)