fix: don't abort parsing packets if they have larger than 0 size

This commit is contained in:
Tamipes 2025-12-07 17:14:58 +01:00
parent f1c1b2c122
commit 5233570675

View file

@ -6,7 +6,6 @@ use tokio::io;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream; use tokio::net::TcpStream;
use tracing::instrument;
use crate::types::VarInt; use crate::types::VarInt;
pub mod clientbound; pub mod clientbound;
@ -81,7 +80,7 @@ impl Packet {
if data_size > u16::MAX.into() { if data_size > u16::MAX.into() {
return Err(ParseError::LengthIsTooBig(length.get_int()).into()); return Err(ParseError::LengthIsTooBig(length.get_int()).into());
} }
if data_size > 0 { if data_size < 0 {
return Err(ParseError::PacketLengthInvalid(length.get_int()).into()); return Err(ParseError::PacketLengthInvalid(length.get_int()).into());
} }
// TODO: this is a bandaid fix; the above checks *should* make sure the // TODO: this is a bandaid fix; the above checks *should* make sure the