aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-17 15:43:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-17 15:43:06 +0200
commitae492d1b359918d20fda817e31675f126c7a7837 (patch)
tree07875355d8c6404d84d4d3aa0e4a60dc88cee562
parentwintun: normalize variable names for their types (diff)
downloadwireguard-go-ae492d1b359918d20fda817e31675f126c7a7837.tar.xz
wireguard-go-ae492d1b359918d20fda817e31675f126c7a7837.zip
device: recheck counters while holding write lock
-rw-r--r--device/noise-protocol.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/device/noise-protocol.go b/device/noise-protocol.go
index dd75cc3..88c6aae 100644
--- a/device/noise-protocol.go
+++ b/device/noise-protocol.go
@@ -315,8 +315,13 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
handshake.chainKey = chainKey
handshake.remoteIndex = msg.Sender
handshake.remoteEphemeral = msg.Ephemeral
- handshake.lastTimestamp = timestamp
- handshake.lastInitiationConsumption = time.Now()
+ if timestamp.After(handshake.lastTimestamp) {
+ handshake.lastTimestamp = timestamp
+ }
+ now := time.Now()
+ if now.After(handshake.lastInitiationConsumption) {
+ handshake.lastInitiationConsumption = now
+ }
handshake.state = HandshakeInitiationConsumed
handshake.mutex.Unlock()