fix limit of undecrytable packets queue length

fixes #517
Also fixes an off-by-one error, such that the queue now holds exactly
protocol.MaxUndecrytablePackets packets when enough undecryptable
packets are received.
This commit is contained in:
Marten Seemann
2017-04-10 17:51:18 +07:00
parent 2a9f214381
commit 8565fdf722
2 changed files with 24 additions and 7 deletions

View File

@@ -782,12 +782,16 @@ func (s *session) tryQueueingUndecryptablePacket(p *receivedPacket) {
if s.cryptoSetup.HandshakeComplete() {
return
}
utils.Infof("Queueing packet 0x%x for later decryption", p.publicHeader.PacketNumber)
if len(s.undecryptablePackets)+1 >= protocol.MaxUndecryptablePackets && s.receivedTooManyUndecrytablePacketsTime.IsZero() {
s.receivedTooManyUndecrytablePacketsTime = time.Now()
s.maybeResetTimer()
if len(s.undecryptablePackets)+1 > protocol.MaxUndecryptablePackets {
// if this is the first time the undecryptablePackets runs full, start the timer to send a Public Reset
if s.receivedTooManyUndecrytablePacketsTime.IsZero() {
s.receivedTooManyUndecrytablePacketsTime = time.Now()
s.maybeResetTimer()
}
utils.Infof("Dropping undecrytable packet 0x%x (undecryptable packet queue full)", p.publicHeader.PacketNumber)
return
}
utils.Infof("Queueing packet 0x%x for later decryption", p.publicHeader.PacketNumber)
s.undecryptablePackets = append(s.undecryptablePackets, p)
}