Repository navigation
Conversation
When the phone reconnects, packets still queued in cmdInput, dataInput
and messageInput from the old connection were consumed by the session
negotiated on the new one. In one case a stale encrypted command was
read as the EAP-AKA Success, which failed to parse ("invalid eap code:
43") and killed the simulator with log.Fatalf.
Drain those queues in the CentralConnected handler, before the new
connection's first command is read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the phone reconnects, packets still queued in
cmdInput,dataInputandmessageInputfrom the old connection get consumed by the session negotiated on the new one. This drains those queues in theCentralConnectedhandler, before the new connection's first command is read.The crash this fixes
The phone connected twice four seconds apart while the sim was re-establishing a session:
The "success" payload is 31 bytes of ciphertext: an encrypted command left in the queue, read where
EapAka()expected the plaintext EAP-Success. The first command was also consumed before the new connection's notifications were set up, so it too came from the earlier connection. On a clean connection a minute earlier the same phone sent the expectedsuccess? 03000004and the session came up normally, so the phone side is fine.Change
drainInputs()does a non-blocking drain of the three input channels.CentralConnectedafter the message loop is stopped andconnGenis bumped. WithLnxMaxConnections(1)the previous central is gone by then, so anything left in the queues belongs to it.Testing
GOOS=linux GOARCH=arm64 go build ./...andgo vet ./pkg/bluetooth/ ./pkg/pod/pass.Not addressed here
EapAka(),StartActivation()and the pairing path read withReadMessage(), which doesn't watchreconnected, so a reconnect in the middle of a handshake can still leave them blocked.log.Fatalf. Restarting the session instead of exiting would make the sim recover from bad input on its own.