From 7f9463320f75b4a754ef9f52da9a9fbb4f36fe56 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 30 Apr 2022 16:56:59 -0500 Subject: [PATCH] fix error that happens in linux + release mode --- azalea-protocol/src/read.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 51224499..2a74d8de 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -118,8 +118,12 @@ where let polled = self.as_mut().stream.as_mut().poll_read(cx, buf); match polled { Poll::Ready(r) => { - if let Some(cipher) = self.as_mut().cipher.get_mut() { - azalea_auth::encryption::decrypt_packet(cipher, buf.initialized_mut()); + // if we don't check for the remaining then we decrypt big packets incorrectly + // (but only on linux and release mode for some reason LMAO) + if buf.remaining() == 0 { + if let Some(cipher) = self.as_mut().cipher.get_mut() { + azalea_auth::encryption::decrypt_packet(cipher, buf.filled_mut()); + } } match r { Ok(()) => Poll::Ready(Ok(())),