This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 7ae1910cd nimble/ll: Null-terminate string in vs_printf HCI event
7ae1910cd is described below

commit 7ae1910cdca5f713e2ecd369b0f5fc46db325d7a
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Thu Oct 17 20:45:39 2024 +0200

    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);
 }
 

Reply via email to