Fix the Security Static Code Analysis - set the length 14/33814/1 tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common tizen_3.0_ivi accepted/tizen/common/20150115.110041 accepted/tizen/ivi/20150116.003606 accepted/tizen/mobile/20150116.011331 accepted/tizen/tv/20150116.010710 accepted/tizen/wearable/20150116.010409 submit/accepted/tizen_common/20150115.102016 submit/accepted/tizen_common/20150115.102032 submit/accepted/tizen_common/20150115.102428 submit/accepted/tizen_common/20150115.102714 submit/tizen/20150115.102847 submit/tizen/20150115.103005 tizen_3.0_ivi_release
authorwu zheng <wu.zheng@intel.com>
Thu, 15 Jan 2015 09:42:17 +0000 (17:42 +0800)
committerwu zheng <wu.zheng@intel.com>
Thu, 15 Jan 2015 09:42:17 +0000 (17:42 +0800)
Fix null terminated issues need to set length+1.

Change-Id: I239c424dc47d6578f2d5845aeff1e88821fd5ff2
Signed-off-by: Wu Zheng <wu.zheng@intel.com>
tools/hcitool.c

index b63d9d5..22a823d 100644 (file)
@@ -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);
                }
        }