From 1edf915bd638e9070a0e49d976836cc8c18d5ede Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Mon, 25 Mar 2024 12:57:41 -0700 Subject: [PATCH] Validate preferred_address transport parameter --- quinn-proto/src/connection/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 27111f1a00..d3f8c5b810 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -3207,6 +3207,19 @@ impl Connection { )); } + if let Some(preferred) = params.preferred_address { + if self.side.is_server() { + return Err(TransportError::TRANSPORT_PARAMETER_ERROR( + "client sent preferred_address", + )); + } + if preferred.connection_id.is_empty() { + return Err(TransportError::TRANSPORT_PARAMETER_ERROR( + "preferred_address must not have a zero-length connection ID", + )); + } + } + self.set_peer_params(params); Ok(())