{"record":{"id":"c8c7dadb882a34f3","repo":"Pumpkin-MC/Pumpkin","slug":"invalid-length","errorCode":null,"errorMessage":"Invalid length","messagePattern":"Invalid length","errorType":"exception","errorClass":"PacketError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/rcon.rs","lineNumber":52,"sourceCode":"impl ClientboundPacket {\n    #[must_use]\n    pub fn write_buf(self, id: i32, body: &str) -> BytesMut {\n        let mut buf = BytesMut::new();\n        // 10 is for 4 bytes ty, 4 bytes id, and 2 terminating nul bytes.\n        buf.put_i32_le(10 + body.len() as i32);\n        buf.put_i32_le(id);\n        buf.put_i32_le(self as i32);\n        let bytes = body.as_bytes();\n        buf.put_slice(bytes);\n        buf.put_u8(0);\n        buf.put_u8(0);\n        buf\n    }\n}\n\n#[derive(Error, Debug)]\npub enum PacketError {\n    #[error(\"Invalid length\")]\n    InvalidLength,\n    #[error(\"Failed to send packet: {0}\")]\n    FailedSend(std::io::Error),\n    #[error(\"Missing packet null terminator\")]\n    MissingNullTerminator,\n    #[error(\"Invalid packet string body: {0}\")]\n    InvalidBody(std::str::Utf8Error),\n    #[error(\"Unknown packet type: {0}\")]\n    UnknownPacketType(i32),\n}\n\n#[derive(Debug, PartialEq, Eq)]\n/// Serverbound packet\npub struct Packet {\n    id: i32,\n    ptype: ServerboundPacket,\n    body: Box<str>,\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/rcon.rs#L34-L70","documentation":"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.","triggerScenarios":"Thrown at crates/pumpkin-protocol/src/rcon.rs:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the malformed RCON packet","Check the length header covers the full received payload","Log the short packet at debug level"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}