From ccb69ca94573c9863fe6324d77dae73ef7c01393 Mon Sep 17 00:00:00 2001 From: wu zheng Date: Thu, 15 Jan 2015 17:42:17 +0800 Subject: Fix the Security Static Code Analysis - set the length Fix null terminated issues need to set length+1. Change-Id: I239c424dc47d6578f2d5845aeff1e88821fd5ff2 Signed-off-by: Wu Zheng --- tools/hcitool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/hcitool.c b/tools/hcitool.c index b63d9d52..22a823df 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -2385,7 +2385,7 @@ failed: static int print_advertising_devices(int dd, uint8_t filter_type) { - unsigned char buf_array[HCI_MAX_EVENT_SIZE] = {0}; + unsigned char buf_array[HCI_MAX_EVENT_SIZE+1] = {0}; unsigned char *buf = buf_array; unsigned char *ptr = NULL; struct hci_filter nf, of; @@ -2419,7 +2419,7 @@ static int print_advertising_devices(int dd, uint8_t filter_type) char addr_array[18]; char *addr = addr_array; - buf_array[HCI_MAX_EVENT_SIZE-1] = 0; + buf[HCI_MAX_EVENT_SIZE] = 0; while ((len = read(dd, buf, HCI_MAX_EVENT_SIZE)) < 0) { if (errno == EINTR && signal_received == SIGINT) { @@ -2452,7 +2452,7 @@ static int print_advertising_devices(int dd, uint8_t filter_type) eir_parse_name(info->data, info->length, name, 29); - name_array[29] = '\0'; + name[29] = '\0'; printf("%s %s\n", addr, name); } } -- cgit v1.2.3