Skip to content

Commit 029540a

Browse files
Yagooraescolar
authored andcommitted
Bluetooth: Controller: Handle overlapping buffers on ull_adv{.c,_aux.c}
* Setting the adv data, scan rsp and adv aux ad data can happen on overlapping buffers * There can be other memcpy's that need to be changed to memmove but these are the only ones I could reproduce the issue and since memmove has a performance penalty, I left the others as is. Signed-off-by: Yago Fontoura do Rosario <[email protected]>
1 parent 5b5d636 commit 029540a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ uint8_t ull_adv_data_set(struct ll_adv_set *adv, uint8_t len,
18701870

18711871
pdu->tx_addr = prev->tx_addr;
18721872
pdu->rx_addr = prev->rx_addr;
1873-
memcpy(&pdu->adv_ind.addr[0], &prev->adv_ind.addr[0], BDADDR_SIZE);
1873+
memmove(&pdu->adv_ind.addr[0], &prev->adv_ind.addr[0], BDADDR_SIZE);
18741874
memcpy(&pdu->adv_ind.data[0], data, len);
18751875
pdu->len = BDADDR_SIZE + len;
18761876

@@ -1926,7 +1926,7 @@ uint8_t ull_scan_rsp_set(struct ll_adv_set *adv, uint8_t len,
19261926
pdu->tx_addr = prev->tx_addr;
19271927
pdu->rx_addr = 0;
19281928
pdu->len = BDADDR_SIZE + len;
1929-
memcpy(&pdu->scan_rsp.addr[0], &prev->scan_rsp.addr[0], BDADDR_SIZE);
1929+
memmove(&pdu->scan_rsp.addr[0], &prev->scan_rsp.addr[0], BDADDR_SIZE);
19301930
memcpy(&pdu->scan_rsp.data[0], data, len);
19311931

19321932
/* Update time reservation */

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv,
20202020

20212021
sec_dptr -= BDADDR_SIZE;
20222022

2023-
(void)memcpy(sec_dptr, bdaddr, BDADDR_SIZE);
2023+
(void)memmove(sec_dptr, bdaddr, BDADDR_SIZE);
20242024
}
20252025

20262026
/* Set the common extended header format flags in the current primary

0 commit comments

Comments
 (0)