samples/bluetooth: Fix mis-use of bt_data 'data' field

The data field is a *pointer* to the buffer, not the actual buffer itself.
Instead of smashing past the end of the struct, write through that pointer.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2022-10-13 15:48:36 -07:00 committed by Johan Hedberg
commit d61d941ec8

View file

@ -490,7 +490,7 @@ static ssize_t write_adv_data(struct bt_conn *conn,
*/
slot->ad[2].data_len = MIN(slot->ad[2].data_len,
len + EDS_URL_WRITE_OFFSET);
memcpy(&slot->ad[2].data + EDS_URL_WRITE_OFFSET, buf,
memcpy((uint8_t *) slot->ad[2].data + EDS_URL_WRITE_OFFSET, buf,
slot->ad[2].data_len - EDS_URL_WRITE_OFFSET);
/* Restart slot */