From 7e1b792dc2a7c169215d799eb72bc8551aff0918 Mon Sep 17 00:00:00 2001 From: draoi Date: Wed, 24 Jul 2024 12:13:18 +0200 Subject: [PATCH] chore: make clippy --- src/net/channel.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/net/channel.rs b/src/net/channel.rs index 81b3f926c..4f0c59805 100644 --- a/src/net/channel.rs +++ b/src/net/channel.rs @@ -264,9 +264,9 @@ impl Channel { } /// Returns a decoded Message command. We start by extracting the length - /// from the stream, then allocate the precise buffer for this length + /// from the stream, then allocate the precise buffer for this length /// using stream.take(). This manual deserialization provides a basic - /// DDOS protection, since it prevents nodes from sending an arbitarily + /// DDOS protection, since it prevents nodes from sending an arbitarily /// large payload. pub async fn read_command( &self, @@ -289,10 +289,9 @@ impl Channel { // Then extract precisely `cmd_len` items from the stream. let mut take = stream.take(cmd_len); - let mut bytes = Vec::new(); // Deserialize into a vector of `cmd_len` size. - bytes.resize(cmd_len.try_into().unwrap(), 0); + let mut bytes = vec![0; cmd_len.try_into().unwrap()]; take.read_exact(&mut bytes).await?; let command = String::from_utf8(bytes)?;