{"record":{"id":"d93c4bf0632046f1","repo":"GitoxideLabs/gitoxide","slug":"leb64-value-overflowed","errorCode":null,"errorMessage":"LEB64 value overflowed","messagePattern":"LEB64 value overflowed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-features/src/decode.rs","lineNumber":19,"sourceCode":"use std::io::Read;\n\n/// Decode variable int numbers from a `Read` implementation.\n#[inline]\npub fn leb64_from_read(mut r: impl Read) -> Result<(u64, usize), std::io::Error> {\n    let mut byte = [0u8; 1];\n    r.read_exact(&mut byte)?;\n    let mut c = byte[0];\n    let mut i = 1;\n    let mut value = u64::from(c) & 0x7f;\n    while c & 0x80 != 0 {\n        r.read_exact(&mut byte)?;\n        c = byte[0];\n        i += 1;\n        value = value\n            .checked_add(1)\n            .and_then(|value| value.checked_shl(7))\n            .and_then(|value| value.checked_add(u64::from(c) & 0x7f))\n            .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, \"LEB64 value overflowed\"))?;\n    }\n    Ok((value, i))\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-features/src/decode.rs#L1-L23","documentation":"gix-features' LEB64 decoder (`leb64_from_read`, used by `from_read`) decodes variable-length 64-bit integers byte by byte with checked arithmetic. This error is raised when the accumulated value would overflow a `u64`, meaning the input stream contains more continuation bytes than a valid LEB64 u64 can have — i.e. malformed or corrupt encoded data.","triggerScenarios":"Calling `gix_features::decode::leb64` / `from_read` on data with 10+ continuation bytes (high bit set), typically from a truncated, corrupted, or adversarially crafted binary stream.","commonSituations":"Reading damaged pack/idx binary data, fuzzing the decoder, or feeding a decoder bytes from the wrong offset so varint boundaries shift.","solutions":["Verify the integrity of the source data (pack checksum) before decoding.","Re-download or re-generate the binary input; the value cannot be represented in u64.","If handling untrusted input, treat this as expected: catch the io::Error with kind InvalidData and reject the input."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match gix_features::decode::leb64(&mut reader) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => /* reject: corrupt varint input */,\n    other => /* continue */,\n}","preventionTips":["Verify binary input checksums before decoding varints.","Never decode at guessed offsets; parse the enclosing structure first.","Fuzz decode paths if you accept untrusted binary data."],"tags":["decoding","binary","overflow","rust"],"backgroundTag":"value-out-of-range","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}