]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: recheck counters while holding write lock
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 17 Oct 2019 13:43:06 +0000 (15:43 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 17 Oct 2019 13:43:06 +0000 (15:43 +0200)
device/noise-protocol.go

index dd75cc3b5571dcfc66838ad57eca8e6749992842..88c6aae174f2ff3677c6580930a5f5ba1d7fb734 100644 (file)
@@ -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()