{"record":{"id":"4b70a1c378edac67","repo":"Pumpkin-MC/Pumpkin","slug":"missing-packet-null-terminator","errorCode":null,"errorMessage":"Missing packet null terminator","messagePattern":"Missing packet null terminator","errorType":"exception","errorClass":"PacketError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/rcon.rs","lineNumber":56,"sourceCode":"        // 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}\n\nimpl Packet {\n    pub fn deserialize(incoming: &mut Vec<u8>) -> Result<Option<Self>, PacketError> {\n        // We need at least 4 bytes to read the packet length header","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/rcon.rs#L38-L74","documentation":"PacketError framing guard while reading an RCON packet: the payload did not end with the required NUL terminator bytes before the declared length ran out. The offending input is the trailing bytes of the RCON body — a client that omitted the terminating NUL(s), indicating a non-conforming or corrupted RCON implementation.","triggerScenarios":"Thrown at crates/pumpkin-protocol/src/rcon.rs:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the malformed packet","Validate the null terminators before reading the body string","Log the malformed 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-17T15:17:12.973Z"}