{"record":{"id":"a36e89e62c989314","repo":"Pumpkin-MC/Pumpkin","slug":"length-too-large-0","errorCode":null,"errorMessage":"Length too large: {0}","messagePattern":"Length too large: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-nbt/src/lib.rs","lineNumber":98,"sourceCode":"    #[error(\"Failed to Cesu 8 Decode\")]\n    Cesu8DecodingError,\n    /// A string could not be decoded as UTF-8.\n    #[error(\"Failed to UTF-8 Decode\")]\n    Utf8DecodingError,\n    /// Serde reported an invalid value or serializer state.\n    #[error(\"Serde error: {0}\")]\n    SerdeError(String),\n    /// The requested Rust type has no NBT representation.\n    #[error(\"NBT doesn't support this type: {0}\")]\n    UnsupportedType(String),\n    /// The underlying reader or writer returned an I/O error.\n    #[error(\"NBT reading was cut short: {0}\")]\n    Incomplete(io::Error),\n    /// A list or array declared a negative element count.\n    #[error(\"Negative list length: {0}\")]\n    NegativeLength(i32),\n    /// A string, list, or array exceeded the supported length.\n    #[error(\"Length too large: {0}\")]\n    LargeLength(usize),\n    /// A Bedrock variable-length integer exceeded its maximum encoded size.\n    #[error(\"Failed to decode varint - value too large\")]\n    VarIntTooLarge,\n    /// A Bedrock variable-length long exceeded its maximum encoded size.\n    #[error(\"Failed to decode varlong - value too large\")]\n    VarLongTooLarge,\n    /// NBT nesting depth exceeded the maximum allowed limit.\n    #[error(\"NBT depth exceeded maximum allowed limit\")]\n    MaxDepthExceeded,\n    /// A list tag specified an invalid element tag type.\n    #[error(\"Invalid element tag type for list: {0}\")]\n    InvalidListTag(u8),\n}\n\n/// A complete NBT document containing a named root compound.\n#[derive(Clone, Debug, Default, PartialEq)]\npub struct Nbt {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-nbt/src/lib.rs#L80-L116","documentation":"This is Error::LargeLength from pumpkin-nbt's Error enum. It is thrown when a string, list, or array declared in the NBT payload exceeds the supported length, preventing huge allocations from hostile or corrupt data.","triggerScenarios":"Deserializing an NBT payload whose length prefix (string length, list len, or array size) exceeds the library's maximum supported size.","commonSituations":"Malformed packets from untrusted clients, corrupted world/level.dat data, or reading Bedrock NBT buffers with a mismatched byte-offset.","solutions":["Validate the length field against your expected payload size before deserializing","Verify you are using the correct NBT variant (Java vs Bedrock) for the data source","Truncate/reject the input and log the offending connection or file"],"exampleFix":"// before\nlet nbt = Nbt::from_reader(&mut cursor).unwrap();\n// after\nmatch Nbt::from_reader(&mut cursor) {\n    Ok(nbt) => nbt,\n    Err(Error::LargeLength(len)) => { log::warn!(\"NBT length too large: {}\", len); return; }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"validation","validationCode":"fn length_ok(len: i32, max: usize) -> bool { len >= 0 && (len as usize) <= max }","typeGuard":null,"tryCatchPattern":"match result { Err(Error::LargeLength(n)) => reject_input(n), Err(e) => propagate(e), Ok(v) => use(v) }","preventionTips":["Sanity-check declared lengths against remaining buffer size before deserializing","Cap incoming payload sizes at the network/framing layer","Use the correct NBT variant for the data source"],"tags":["nbt","deserialization","malformed-data"],"backgroundTag":"value-out-of-range","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}