diff options
Diffstat (limited to 'tools/hcitool.c')
-rw-r--r-- | tools/hcitool.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c index 648a0f7d..2c84dc7d 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -2404,7 +2404,9 @@ failed: static int print_advertising_devices(int dd, uint8_t filter_type) { - unsigned char buf[HCI_MAX_EVENT_SIZE], *ptr; + unsigned char buf_array[HCI_MAX_EVENT_SIZE+1] = {0}; + unsigned char *buf = buf_array; + unsigned char *ptr = NULL; struct hci_filter nf, of; struct sigaction sa; socklen_t olen; @@ -2431,11 +2433,14 @@ static int print_advertising_devices(int dd, uint8_t filter_type) sigaction(SIGINT, &sa, NULL); while (1) { - evt_le_meta_event *meta; - le_advertising_info *info; - char addr[18]; + evt_le_meta_event *meta = NULL; + le_advertising_info *info = NULL; + char addr_array[18]; + char *addr = addr_array; + + buf[HCI_MAX_EVENT_SIZE] = 0; - while ((len = read(dd, buf, sizeof(buf))) < 0) { + while ((len = read(dd, buf, HCI_MAX_EVENT_SIZE)) < 0) { if (errno == EINTR && signal_received == SIGINT) { len = 0; goto done; @@ -2457,14 +2462,16 @@ static int print_advertising_devices(int dd, uint8_t filter_type) /* Ignoring multiple reports */ info = (le_advertising_info *) (meta->data + 1); if (check_report_filter(filter_type, info)) { - char name[30]; + char name_array[30]; + char *name = name_array; - memset(name, 0, sizeof(name)); + memset(name, 0, 30); ba2str(&info->bdaddr, addr); eir_parse_name(info->data, info->length, - name, sizeof(name) - 1); + name, 29); + name[29] = '\0'; printf("%s %s\n", addr, name); } } |