From a9dcf11781ef7ac0390aa44994efc9e692b3eed7 Mon Sep 17 00:00:00 2001 From: Ian Campbell <52475242+xv-ian-c@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:18:55 +0000 Subject: [PATCH] lightway-core: Ignore `wire::Frame::Data{Frag}` until `State::Online` Data packets (whether fragmented or not) received from outside should not be forwarded out of the inside path until the connection is `Online` or after it has begun the disconnect process. We already correctly do this for data received on the inside path, in `Connection::inside_data_received`. --- lightway-core/src/connection.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lightway-core/src/connection.rs b/lightway-core/src/connection.rs index acd746a..9684537 100644 --- a/lightway-core/src/connection.rs +++ b/lightway-core/src/connection.rs @@ -1334,6 +1334,10 @@ impl Connection { } fn handle_outside_data_packet(&mut self, data: wire::Data) -> ConnectionResult<()> { + if !matches!(self.state, State::Online) { + return Err(ConnectionError::InvalidState); + } + // into_owned should be a NOP here since // `wire::Data::try_from_wire` produced a `Cow::Owned` // variant. @@ -1341,6 +1345,10 @@ impl Connection { } fn handle_outside_data_fragment(&mut self, frag: wire::DataFrag) -> ConnectionResult<()> { + if !matches!(self.state, State::Online) { + return Err(ConnectionError::InvalidState); + } + match self.fragment_map.add_fragment(frag) { FragmentMapResult::Complete(data) => { self.handle_outside_data_bytes(data)?;