device: Disable auto connect for temporary devices
authorYu Liu <yudiliu@google.com>
Thu, 24 Sep 2020 23:17:42 +0000 (16:17 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
When connecting a LE keyboard, if the user input the wrong passkey, the
stack would keep auto connect and thus allow the user to retry the
passkey indefinitely which is a security concern. This fix would
disallow the auto connect if the authentication failed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/device.c

index 0c85002..7b78fde 100644 (file)
@@ -8839,6 +8839,10 @@ void btd_device_set_temporary(struct btd_device *device, bool temporary)
                if (device->bredr)
                        adapter_whitelist_remove(device->adapter, device);
                adapter_connect_list_remove(device->adapter, device);
+               if (device->auto_connect) {
+                       device->disable_auto_connect = TRUE;
+                       device_set_auto_connect(device, FALSE);
+               }
                device->temporary_timer = g_timeout_add_seconds(main_opts.tmpto,
                                                        device_disappeared,
                                                        device);
@@ -9290,8 +9294,9 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
                 * treated as a newly discovered device.
                 */
                if (!device_is_paired(device, bdaddr_type) &&
-                               !device_is_trusted(device))
+                               !device_is_trusted(device)) {
                        btd_device_set_temporary(device, true);
+               }
 
                device_bonding_failed(device, status);
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY