1
mirror of https://github.com/Yubico/python-fido2 synced 2024-09-29 07:09:42 +02:00

Linux: Fail gracefully on invalid HIDIOCGRAWUNIQ

This commit is contained in:
Rasmus Précenth 2021-11-05 13:45:11 +01:00 committed by Dain Nilsson
parent 0ca5ca14b5
commit e78efbfe93
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -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)