Fix the remaining Security Static Code Analysis 28/33728/1 accepted/tizen/common/20150114.145919 accepted/tizen/ivi/20150115.062849 accepted/tizen/mobile/20150115.021557 accepted/tizen/tv/20150115.004531 accepted/tizen/wearable/20150115.004810 submit/tizen/20150114.083556
authorwu zheng <wu.zheng@intel.com>
Wed, 14 Jan 2015 08:20:30 +0000 (16:20 +0800)
committerwu zheng <wu.zheng@intel.com>
Wed, 14 Jan 2015 08:20:30 +0000 (16:20 +0800)
the latest item of array need to be set to 0.

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

index da38052..722adcb 100644 (file)
@@ -2419,7 +2419,9 @@ static int print_advertising_devices(int dd, uint8_t filter_type)
                char addr_array[18];
                char *addr = addr_array;
 
-               while ((len = read(dd, buf, sizeof(buf))) < 0) {
+               buf_array[HCI_MAX_EVENT_SIZE] = 0;
+
+               while ((len = read(dd, buf, HCI_MAX_EVENT_SIZE)) < 0) {
                        if (errno == EINTR && signal_received == SIGINT) {
                                len = 0;
                                goto done;
@@ -2450,6 +2452,8 @@ static int print_advertising_devices(int dd, uint8_t filter_type)
                        eir_parse_name(info->data, info->length,
                                                        name, 29);
 
+                       addr_array[18] = '\0';
+                       name_array[30] = '\0';
                        printf("%s %s\n", addr, name);
                }
        }