From d65f908a125d7d250f75f74eb4a19718dfd14fd5 Mon Sep 17 00:00:00 2001 From: Szymon Czapracki Date: Thu, 8 Aug 2024 15:34:08 +0200 Subject: [PATCH] nimble/audio: Modify BASS control point write access Modify BASS control point write access in a way that it would use proper mbuf for holding incoming data. Fix handler check from simple bool comparison to ensuring that it's not NULL. --- .../host/audio/services/bass/src/ble_audio_svc_bass.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c index 1c4ff639e..f4fe11270 100644 --- a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c +++ b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c @@ -618,12 +618,16 @@ static int ble_svc_audio_bass_ctrl_point_write_access(struct ble_gatt_access_ctxt *ctxt, uint16_t conn_handle) { struct ble_svc_audio_bass_ctrl_point_handler *handler; + uint16_t mbuf_len = OS_MBUF_PKTLEN(ctxt->om); + uint8_t opcode; + uint8_t data[MYNEWT_VAL(BLE_SVC_AUDIO_BASS_METADATA_MAX_SZ)]; - uint8_t opcode = ctxt->om->om_data[0]; + os_mbuf_copydata(ctxt->om, 0, mbuf_len, data); + opcode = data[0]; handler = ble_svc_audio_bass_find_handler(opcode); - if (!handler) { + if (handler == NULL) { return BLE_SVC_AUDIO_BASS_ERR_OPCODE_NOT_SUPPORTED; } @@ -633,7 +637,7 @@ ble_svc_audio_bass_ctrl_point_write_access(struct ble_gatt_access_ctxt *ctxt, ui return BLE_ATT_ERR_WRITE_REQ_REJECTED; } - return handler->handler_cb(&ctxt->om->om_data[1], ctxt->om->om_len - 1, conn_handle); + return handler->handler_cb(data, mbuf_len, conn_handle); } static int