From e1a3675439116c00a5bd5e14b5b539b0193db59e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 17 Jul 2019 10:07:11 +1000 Subject: [PATCH] base: ignore anything not from the known vendor IDs We don't want to accidentally start talking to a device and brick it. --- tuhi/base.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tuhi/base.py b/tuhi/base.py index 548bb5d..b0934d2 100644 --- a/tuhi/base.py +++ b/tuhi/base.py @@ -333,9 +333,6 @@ class Tuhi(GObject.Object): @classmethod def _device_in_register_mode(cls, bluez_device): - if bluez_device.vendor_id not in WACOM_COMPANY_IDS: - return False - # When the device is in register mode (blue light blinking), the # manufacturer is merely 4 bytes. This will reset to 7 bytes even # when the device simply times out and does not register fully. @@ -368,16 +365,17 @@ class Tuhi(GObject.Object): stage. ''' - uuid = None + # We have a reverse-engineered protocol. Let's not talk to anyone + # who doesn't look like we know them to avoid potentially bricking a + # device. + if bluez_device.vendor_id not in WACOM_COMPANY_IDS: + return # check if the device is already known to us try: config = self.config.devices[bluez_device.address] uuid = config['uuid'] except KeyError: - pass - - if uuid is None and bluez_device.vendor_id not in WACOM_COMPANY_IDS: return # if we got here from a currently live BlueZ device,