Skip to content

Commit 7ae1910

Browse files
nimble/ll: Null-terminate string in vs_printf HCI event
This allows app on host to simply print the contents of event.
1 parent 5191a4e commit 7ae1910

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nimble/controller/src/ble_ll_hci_ev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...)
618618
struct ble_hci_ev_vs *ev;
619619
struct ble_hci_ev *hci_ev;
620620
va_list ap;
621+
int len;
621622

622623
hci_ev = ble_transport_alloc_evt(1);
623624
if (!hci_ev) {
@@ -631,10 +632,12 @@ ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...)
631632
ev->id = id;
632633

633634
va_start(ap, fmt);
634-
hci_ev->length += vsnprintf((void *)ev->data,
635-
BLE_HCI_MAX_DATA_LEN - sizeof(*ev), fmt, ap);
635+
len = vsnprintf((void *)ev->data, BLE_HCI_MAX_DATA_LEN - sizeof(*ev), fmt, ap);
636636
va_end(ap);
637637

638+
ev->data[len] = 0;
639+
hci_ev->length += len + 1;
640+
638641
ble_ll_hci_event_send(hci_ev);
639642
}
640643

0 commit comments

Comments
 (0)