You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(hid): enforce wall-clock timeout on HID receive and CTAP2 exchanges
hidapi `read_timeout` returns `Ok(0)` on timeout (not an error) and the
leftover zero-initialised buffer used to be silently dropped by the
parser, so a stalled or unplugged device could hang `hid_recv_hidapi`
indefinitely. Additionally, the CTAP2 protocol layer did not wrap the
`cbor_send`/`cbor_recv` pair in any wall-clock timeout (unlike CTAP1).
Changes:
- `hid_recv_hidapi` now caps each blocking read to a short poll
interval, tracks the overall deadline across iterations, treats
`Ok(0)` byte counts as per-iteration timeouts to retry against the
remaining budget, and returns `TransportError::Timeout` once the
budget is exhausted.
- `hid_recv` sends `CTAPHID_CANCEL` on `TransportError::Timeout` in
addition to `PlatformError::Cancelled`, per CTAP 2.2 §11.2.9.1.5.
- A new `cbor_send_recv` helper wraps the CTAP2 send/recv pair in
`tokio::time::timeout` and is used by every `ctap2_*` method on the
`Ctap2` trait, mirroring `send_apdu_request_wait_uv` in the CTAP1
protocol module.
Spec refs:
- CTAP 2.2 §11.2 USB HID transport
- CTAP 2.2 §11.2.9.1.5 CTAPHID_CANCEL
0 commit comments