aboutsummaryrefslogtreecommitdiff
path: root/device/peer.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-04-05 18:51:15 -0600
committerDavid Crawshaw <crawshaw@tailscale.com>2020-05-02 01:16:08 +1000
commit682401a17792d2508aca967834acef4c2897b8e4 (patch)
tree371c91179a7a205f2ac7f1761fbb4ade7cf1d182 /device/peer.go
parent1ecbb3313cbac6ad2db09ecca728a835568fcdd8 (diff)
downloadwireguard-go-682401a17792d2508aca967834acef4c2897b8e4.tar.gz
wireguard-go-682401a17792d2508aca967834acef4c2897b8e4.zip
device: use atomic access for unlocked keypair.next
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/peer.go')
-rw-r--r--device/peer.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/device/peer.go b/device/peer.go
index cb348d5..94182e7 100644
--- a/device/peer.go
+++ b/device/peer.go
@@ -226,10 +226,10 @@ func (peer *Peer) ZeroAndFlushAll() {
keypairs.Lock()
device.DeleteKeypair(keypairs.previous)
device.DeleteKeypair(keypairs.current)
- device.DeleteKeypair(keypairs.next)
+ device.DeleteKeypair(keypairs.LoadNext())
keypairs.previous = nil
keypairs.current = nil
- keypairs.next = nil
+ keypairs.StoreNext(nil)
keypairs.Unlock()
// clear handshake state
@@ -257,7 +257,7 @@ func (peer *Peer) ExpireCurrentKeypairs() {
keypairs.current.sendNonce = RejectAfterMessages
}
if keypairs.next != nil {
- keypairs.next.sendNonce = RejectAfterMessages
+ keypairs.LoadNext().sendNonce = RejectAfterMessages
}
keypairs.Unlock()
}