GitoxideLabs/gitoxide · error
LEB64 value overflowed
Error message
LEB64 value overflowed
What it means
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.
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.
Defensive patterns
Strategy: try-catch
Try / catch
match gix_features::decode::leb64(&mut reader) {
Err(e) if e.kind() == std::io::ErrorKind::InvalidData => /* reject: corrupt varint input */,
other => /* continue */,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Reading damaged pack/idx binary data, fuzzing the decoder, or feeding a decoder bytes from the wrong offset so varint boundaries shift.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Failed to subtract from
- base graph count to fit in 32-bits
- number of commits in CDAT chunk to fit in 32 bits
- ' ' is not a valid configuration key
- Cannot use iter_v1() on index of type
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/d93c4bf0632046f1.
Report an issue: GitHub.
Appendix: source
Thrown at gix-features/src/decode.rs:19
use std::io::Read;
/// Decode variable int numbers from a `Read` implementation.
#[inline]
pub fn leb64_from_read(mut r: impl Read) -> Result<(u64, usize), std::io::Error> {
let mut byte = [0u8; 1];
r.read_exact(&mut byte)?;
let mut c = byte[0];
let mut i = 1;
let mut value = u64::from(c) & 0x7f;
while c & 0x80 != 0 {
r.read_exact(&mut byte)?;
c = byte[0];
i += 1;
value = value
.checked_add(1)
.and_then(|value| value.checked_shl(7))
.and_then(|value| value.checked_add(u64::from(c) & 0x7f))
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, "LEB64 value overflowed"))?;
}
Ok((value, i))
}
View on GitHub (pinned to e73179060b)