From 7ae1910cdca5f713e2ecd369b0f5fc46db325d7a Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Thu, 17 Oct 2024 20:45:39 +0200 Subject: [PATCH] nimble/ll: Null-terminate string in vs_printf HCI event This allows app on host to simply print the contents of event. --- nimble/controller/src/ble_ll_hci_ev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nimble/controller/src/ble_ll_hci_ev.c b/nimble/controller/src/ble_ll_hci_ev.c index 06d370687..8d088d9da 100644 --- a/nimble/controller/src/ble_ll_hci_ev.c +++ b/nimble/controller/src/ble_ll_hci_ev.c @@ -618,6 +618,7 @@ ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...) struct ble_hci_ev_vs *ev; struct ble_hci_ev *hci_ev; va_list ap; + int len; hci_ev = ble_transport_alloc_evt(1); if (!hci_ev) { @@ -631,10 +632,12 @@ ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...) ev->id = id; va_start(ap, fmt); - hci_ev->length += vsnprintf((void *)ev->data, - BLE_HCI_MAX_DATA_LEN - sizeof(*ev), fmt, ap); + len = vsnprintf((void *)ev->data, BLE_HCI_MAX_DATA_LEN - sizeof(*ev), fmt, ap); va_end(ap); + ev->data[len] = 0; + hci_ev->length += len + 1; + ble_ll_hci_event_send(hci_ev); }