Pumpkin-MC/Pumpkin · error · PacketError
Invalid length
Error message
Invalid length
What it means
PacketError guard for RCON packet framing: the length prefix of an RCON packet (used for both requests and responses) is invalid — negative, smaller than the minimum 10-byte body, or otherwise out of the plausible range. The offending input is the 4-byte little-endian length field of the RCON packet; a bad value means a malformed or hostile RCON client.
Solutions
- Drop the malformed RCON packet
- Check the length header covers the full received payload
- Log the short packet at debug level
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/pumpkin-protocol/src/rcon.rs:52 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/c8c7dadb882a34f3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-protocol/src/rcon.rs:52
impl ClientboundPacket {
#[must_use]
pub fn write_buf(self, id: i32, body: &str) -> BytesMut {
let mut buf = BytesMut::new();
// 10 is for 4 bytes ty, 4 bytes id, and 2 terminating nul bytes.
buf.put_i32_le(10 + body.len() as i32);
buf.put_i32_le(id);
buf.put_i32_le(self as i32);
let bytes = body.as_bytes();
buf.put_slice(bytes);
buf.put_u8(0);
buf.put_u8(0);
buf
}
}
#[derive(Error, Debug)]
pub enum PacketError {
#[error("Invalid length")]
InvalidLength,
#[error("Failed to send packet: {0}")]
FailedSend(std::io::Error),
#[error("Missing packet null terminator")]
MissingNullTerminator,
#[error("Invalid packet string body: {0}")]
InvalidBody(std::str::Utf8Error),
#[error("Unknown packet type: {0}")]
UnknownPacketType(i32),
}
#[derive(Debug, PartialEq, Eq)]
/// Serverbound packet
pub struct Packet {
id: i32,
ptype: ServerboundPacket,
body: Box<str>,
}View on GitHub (pinned to 8d4639e25a)