From 289d8276ebb977304f5074bd1e4626d2e98215dd Mon Sep 17 00:00:00 2001 From: Andrew Kozlik <42678794+andrewkozlik@users.noreply.github.com> Date: Sat, 11 Jan 2020 14:33:24 +0100 Subject: [PATCH] core/fido2: check for HID timeout in send_cmd() (#791) --- core/src/apps/webauthn/fido2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/apps/webauthn/fido2.py b/core/src/apps/webauthn/fido2.py index fad5280107..9ef33f9277 100644 --- a/core/src/apps/webauthn/fido2.py +++ b/core/src/apps/webauthn/fido2.py @@ -477,7 +477,10 @@ async def send_cmd(cmd: Cmd, iface: io.HID) -> None: if copied < _FRAME_CONT_SIZE: frm.data[copied:] = bytearray(_FRAME_CONT_SIZE - copied) while True: - await write + ret = await loop.race(write, loop.sleep(_CTAP_HID_TIMEOUT_MS * 1000)) + if ret is not None: + raise TimeoutError + if iface.write(buf) > 0: break seq += 1