{"record":{"id":"8c045b7251056d93","repo":"janhq/jan","slug":"array-length-is-unreasonably-large","errorCode":null,"errorMessage":"Array length {} is unreasonably large","messagePattern":"Array length (.+?) is unreasonably large","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/helpers.rs","lineNumber":182,"sourceCode":"        GgufValueType::Uint8 => Ok(reader.read_u8()?.to_string()),\n        GgufValueType::Int8 => Ok(reader.read_i8()?.to_string()),\n        GgufValueType::Uint16 => Ok(reader.read_u16::<LittleEndian>()?.to_string()),\n        GgufValueType::Int16 => Ok(reader.read_i16::<LittleEndian>()?.to_string()),\n        GgufValueType::Uint32 => Ok(reader.read_u32::<LittleEndian>()?.to_string()),\n        GgufValueType::Int32 => Ok(reader.read_i32::<LittleEndian>()?.to_string()),\n        GgufValueType::Float32 => Ok(reader.read_f32::<LittleEndian>()?.to_string()),\n        GgufValueType::Bool => Ok((reader.read_u8()? != 0).to_string()),\n        GgufValueType::String => read_gguf_string(reader),\n        GgufValueType::Uint64 => Ok(reader.read_u64::<LittleEndian>()?.to_string()),\n        GgufValueType::Int64 => Ok(reader.read_i64::<LittleEndian>()?.to_string()),\n        GgufValueType::Float64 => Ok(reader.read_f64::<LittleEndian>()?.to_string()),\n        GgufValueType::Array => {\n            let elem_type_u32 = reader.read_u32::<LittleEndian>()?;\n            let elem_type = GgufValueType::try_from(elem_type_u32)?;\n            let len = reader.read_u64::<LittleEndian>()?;\n\n            if len > 1_000_000 {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    format!(\"Array length {} is unreasonably large\", len),\n                ));\n            }\n\n            if len > 24 {\n                skip_array_data(reader, elem_type, len)?;\n                return Ok(format!(\n                    \"<Array of type {:?} with {} elements, data skipped>\",\n                    elem_type, len\n                ));\n            }\n\n            let mut elems = Vec::with_capacity(len as usize);\n            for _ in 0..len {\n                elems.push(read_gguf_value(reader, elem_type)?);\n            }\n            Ok(format!(\"[{}]\", elems.join(\", \")))","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/helpers.rs#L164-L200","documentation":"read_gguf_value rejects a GGUF array KV value whose element count exceeds 1,000,000. Large real arrays (e.g. tokenizer vocabularies) exist but are normally far below this; a bigger length indicates corruption or a desynchronized walk, so the parser bails instead of looping or seeking billions of bytes.","triggerScenarios":"Reading a GGUF metadata value of type Array whose u64 length prefix exceeds 1,000,000 - corruption, wrong offset parsing, or a malformed KV entry.","commonSituations":"Corrupted model files, parsing desynchronization after an earlier malformed entry, adversarial/fuzzed files, buggy conversion tools writing wrong array lengths.","solutions":["Re-download the model file and verify its checksum","Inspect the KV section with llama.cpp's gguf_dump to find the malformed array entry","Check whether the parser desynchronized earlier (nested 'Error reading metadata entry' messages)","If you legitimately need larger arrays, raise the 1,000,000 bound in read_gguf_value and rebuild"],"exampleFix":"// before\nlet meta = read_gguf_metadata(File::open(\"corrupt.gguf\")?)?;\n// after\nlet digest = sha256_file(\"corrupt.gguf\")?;\nassert_eq!(digest, publisher_sha256, \"file corrupt - re-download\");\nlet meta = read_gguf_metadata(File::open(\"corrupt.gguf\")?)?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match read_gguf_metadata(file) {\n    Err(e) if e.to_string().contains(\"Array length\") => {\n        eprintln!(\"GGUF KV array corrupt or unsupported: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Verify checksums before parsing model files","Use gguf_dump to inspect KV arrays in new model files","Update the parser bound only after confirming a legitimate need"],"tags":["gguf","metadata","array","corrupt-file","binary-parsing"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}