Fix the error array value overflow 99/33799/1 submit/accepted/tizen_common/20150115.053946 submit/tizen/20150115.100801
authorwu zheng <wu.zheng@intel.com>
Thu, 15 Jan 2015 05:23:24 +0000 (13:23 +0800)
committerwu zheng <wu.zheng@intel.com>
Thu, 15 Jan 2015 05:23:24 +0000 (13:23 +0800)
The array value overflow in the print function of hcitool.c.
Fix it.

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

index 722adcb..b63d9d5 100644 (file)
@@ -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] = 0;
+               buf_array[HCI_MAX_EVENT_SIZE-1] = 0;
 
                while ((len = read(dd, buf, HCI_MAX_EVENT_SIZE)) < 0) {
                        if (errno == EINTR && signal_received == SIGINT) {
@@ -2452,8 +2452,7 @@ 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';
+                       name_array[29] = '\0';
                        printf("%s %s\n", addr, name);
                }
        }