device: fix races from changing private_key

Access keypair.sendNonce atomically.
Eliminate one unnecessary initialization to zero.

Mutate handshake.lastSentHandshake with the mutex held.

Co-authored-by: David Anderson <[email protected]>
Signed-off-by: Josh Bleecher Snyder <[email protected]>
This commit is contained in:
Josh Bleecher Snyder
2021-01-07 14:49:44 +01:00
committed by Jason A. Donenfeld
co-authored by David Anderson
parent c8faa34cde
commit 70861686d3
5 changed files with 32 additions and 11 deletions
-1
View File
@@ -566,7 +566,6 @@ func (peer *Peer) BeginSymmetricSession() error {
setZero(recvKey[:])
keypair.created = time.Now()
keypair.sendNonce = 0
keypair.replayFilter.Reset()
keypair.isInitiator = isInitiator
keypair.localIndex = peer.handshake.localIndex