From 1fd966f210a1060d9faa95f4c89e37af455c6473 Mon Sep 17 00:00:00 2001 From: Hugo Planque <12386279+HookWoods@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:48:42 +0100 Subject: [PATCH] fix(protocol): Don't reserve memory on packet decoding error (#360) * fix(protocol): Don't reserve memory on packet decoding error * fix: revert packet_decoder fix part, this need more test for the moment * fix: drop the connection on decoding error to avoid possible attack --- pumpkin/src/client/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index 1d9dcd8e..40efd28e 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -503,7 +503,11 @@ impl Client { return true; } Ok(None) => (), //log::debug!("Waiting for more data to complete packet..."), - Err(err) => log::warn!("Failed to decode packet for: {}", err.to_string()), + Err(err) => { + log::warn!("Failed to decode packet for: {}", err.to_string()); + self.close(); + return false; // return to avoid reserving additional bytes + } } dec.reserve(4096);