Skip to content

fix(ble): ignore packets on a disposed gateway and drop malformed fragments - #5

Open
sethforprivacy wants to merge 2 commits into
improved-passphrasesfrom
cw/robust-ble-gateway
Open

sethforprivacy wants to merge 2 commits into
improved-passphrasesfrom
cw/robust-ble-gateway

Conversation

@sethforprivacy

Copy link
Copy Markdown

QA hit Bad state: Not enough bytes to read from CrcValidator.onTransform after a Trezor Safe 7 timed out, the user started the key-image sync, and the device auto-reconnected: a stale/truncated BLE notification reached the gateway and the bare StateError surfaced as an app error.

  • Ignore notifications once the gateway is disposed (link lost, reconnect in progress) and empty payloads.
  • Drop packets that cannot be decoded (reset the partial reassembly) instead of failing the pending request; device-reported THP errors (TrezorException) still propagate.

Based on 0277176 (the commit Cake Wallet pins); Cake pins this branch in cake-tech/cake_wallet#3631.

🤖 Generated with Claude Code

sethforprivacy and others added 2 commits September 17, 2026 09:04
…gments

After a link drop and reconnect a stale or truncated notification could
reach the gateway; the CRC validator then failed with a bare
StateError ("Not enough bytes to read") that surfaced as an app error.
Ignore packets once the gateway is disposed, and drop packets that cannot
be decoded (resetting the partial reassembly) instead of failing the
pending request. Device-reported THP errors still propagate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The base picked up the same disposed-gateway / malformed-packet handling in
trezor_gatt_gateway.dart; the only difference was this branch's explanatory
comments, so they are kept. Brings in the trezor_client.dart safeguards.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant