From 524f7294d1d57daf3178552099b9f80f6f44e19b Mon Sep 17 00:00:00 2001 From: viktorking7 <140458814+viktorking7@users.noreply.github.com> Date: Tue, 23 Sep 2025 17:48:10 +0200 Subject: [PATCH] Update codec.rs --- protocols/rendezvous/src/codec.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/protocols/rendezvous/src/codec.rs b/protocols/rendezvous/src/codec.rs index 60f9f14f332..4441701c7ba 100644 --- a/protocols/rendezvous/src/codec.rs +++ b/protocols/rendezvous/src/codec.rs @@ -59,6 +59,11 @@ impl Namespace { /// are enforcing a `static lifetime which means this value can only be a constant in the /// program and hence we hope the developer checked that it is of an acceptable length. pub fn from_static(value: &'static str) -> Self { + // Empty namespaces are ambiguous on the wire encoding (would be indistinguishable from + // `None`). Disallow empty values to avoid semantic collisions. + if value.is_empty() { + panic!("Namespace must not be empty"); + } if value.len() > crate::MAX_NAMESPACE { panic!("Namespace '{value}' is too long!") } @@ -67,6 +72,11 @@ impl Namespace { } pub fn new(value: String) -> Result { + // Empty namespaces are ambiguous on the wire encoding (would be indistinguishable from + // `None`). Disallow empty values to avoid semantic collisions. + if value.is_empty() { + return Err(NamespaceTooLong); + } if value.len() > crate::MAX_NAMESPACE { return Err(NamespaceTooLong); }