From e78efbfe93deb6fd7acb9eb0cf8753a22fc0dd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Pr=C3=A9centh?= Date: Fri, 5 Nov 2021 13:45:11 +0100 Subject: [PATCH] Linux: Fail gracefully on invalid HIDIOCGRAWUNIQ --- fido2/hid/linux.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fido2/hid/linux.py b/fido2/hid/linux.py index 2343fbf..f403444 100644 --- a/fido2/hid/linux.py +++ b/fido2/hid/linux.py @@ -57,9 +57,12 @@ def get_descriptor(path): name = bytearray(buf[: (length - 1)]).decode("utf-8") if length > 1 else None # Read unique ID - buf = array("B", [0] * 64) - length = fcntl.ioctl(f, HIDIOCGRAWUNIQ, buf, True) - serial = bytearray(buf[: (length - 1)]).decode("utf-8") if length > 1 else None + try: + buf = array("B", [0] * 64) + length = fcntl.ioctl(f, HIDIOCGRAWUNIQ, buf, True) + serial = bytearray(buf[: (length - 1)]).decode("utf-8") if length > 1 else None + except OSError: + serial = None # Read report descriptor buf = array("B", [0] * 4)