From 728b758bb81eba821a6d8d461fddbcbc58eeeec2 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Mon, 9 Dec 2019 22:10:34 -0800 Subject: [PATCH] Fix panic in anti-amplification corner case --- quinn-proto/src/connection.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/quinn-proto/src/connection.rs b/quinn-proto/src/connection.rs index 453c2928d..367975239 100644 --- a/quinn-proto/src/connection.rs +++ b/quinn-proto/src/connection.rs @@ -581,9 +581,18 @@ where } // Send two probes to improve odds of getting through under lossy conditions - let (_, space) = self + let space = self .earliest_time_and_space(|x| x.time_of_last_sent_ack_eliciting_packet) - .unwrap(); + .map(|(_, space)| space) + .unwrap_or_else(|| { + // PTO expired with no sent ack-eliciting packets! This should only happen on a + // client that's discarded the initial packet space but hasn't received enough data + // from the server to send an ack-eliciting handshake packet + // yet. https://github.com/quicwg/base-drafts/pull/3162 will change the behavior + // here, but for now we generate an anti-amplification packet at handshake level. + debug_assert!(self.side.is_client() && self.highest_space == SpaceId::Handshake); + SpaceId::Handshake + }); trace!( in_flight = self.in_flight.bytes, count = self.pto_count,