diff options
author | Josh Bleecher Snyder <josh@tailscale.com> | 2020-12-15 15:02:13 -0800 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-07 14:49:44 +0100 |
commit | 70861686d3005de91b45d38e5b16fd3132a4a872 (patch) | |
tree | c235b16ab7aae0907f4276feef66239eb820a29b /device/send.go | |
parent | c8faa34cdee37d9bcb588675e2385024bef86c18 (diff) | |
download | wireguard-go-70861686d3005de91b45d38e5b16fd3132a4a872.tar.gz wireguard-go-70861686d3005de91b45d38e5b16fd3132a4a872.zip |
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 <danderson@tailscale.com>
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/send.go')
-rw-r--r-- | device/send.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/device/send.go b/device/send.go index 6b21708..bc51fa6 100644 --- a/device/send.go +++ b/device/send.go @@ -403,7 +403,7 @@ NextPacket: // check validity of newest key pair keypair = peer.keypairs.Current() - if keypair != nil && keypair.sendNonce < RejectAfterMessages { + if keypair != nil && atomic.LoadUint64(&keypair.sendNonce) < RejectAfterMessages { if time.Since(keypair.created) < RejectAfterTime { break } |