Fix the crash issue to parse the device name 08/218608/1 accepted/tizen/unified/20191128.001540 submit/tizen/20191127.050440
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 26 Nov 2019 04:37:47 +0000 (13:37 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 26 Nov 2019 04:37:47 +0000 (13:37 +0900)
Change-Id: I29976c3479eafb15085f5ebf6679e123b51774ea
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
src/bluetooth-adapter.c

index 27859c6..348a5ae 100644 (file)
@@ -3087,6 +3087,12 @@ int bt_adapter_le_get_scan_result_device_name(const bt_adapter_le_device_scan_re
                field_len = adv_data[0];
                if (adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_LOCAL_NAME ||
                        adv_data[1] == BT_ADAPTER_LE_ADVERTISING_DATA_SHORT_LOCAL_NAME) {
+
+                       if (field_len <= 0) {
+                               BT_ERR("Wrong field len for name");
+                               return BT_ERROR_NO_DATA;
+                       }
+
                        *name = g_malloc0(sizeof(char) *field_len);
                        memcpy(*name, &adv_data[2], field_len - 1);