{"record":{"id":"4f3a667f9358f37c","repo":"rustfs/rustfs","slug":"varint-overflow","errorCode":null,"errorMessage":"varint overflow","messagePattern":"varint overflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rio-v2/src/s2_index.rs","lineNumber":347,"sourceCode":"        unsigned >>= 7;\n    }\n    out.push(unsigned as u8);\n}\n\nfn read_varint(bytes: &[u8]) -> io::Result<(i64, usize)> {\n    let (unsigned, used) = read_uvarint(bytes)?;\n    let value = ((unsigned >> 1) as i64) ^ (-((unsigned & 1) as i64));\n    Ok((value, used))\n}\n\nfn read_uvarint(bytes: &[u8]) -> io::Result<(u64, usize)> {\n    let mut value = 0_u64;\n    let mut shift = 0_u32;\n\n    for (idx, byte) in bytes.iter().copied().enumerate() {\n        if byte < 0x80 {\n            if idx > 9 || (idx == 9 && byte > 1) {\n                return Err(io::Error::new(io::ErrorKind::InvalidData, \"varint overflow\"));\n            }\n            return Ok((value | ((byte as u64) << shift), idx + 1));\n        }\n\n        value |= ((byte & 0x7f) as u64) << shift;\n        shift += 7;\n    }\n\n    Err(io::Error::new(io::ErrorKind::UnexpectedEof, \"unexpected EOF while reading varint\"))\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn signed_varint_matches_go_binary_varint_examples() {\n        let cases = [","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/rustfs/rustfs/blob/9e6e02ea09c86bedf44c7bd64a74ea02a0cff1de/crates/rio-v2/src/s2_index.rs#L329-L365","documentation":"Error \"varint overflow\" thrown in rustfs/rustfs.","triggerScenarios":"Thrown at crates/rio-v2/src/s2_index.rs:347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9e6e02ea09c86bedf44c7bd64a74ea02a0cff1de","analyzedAt":"2026-08-16T20:34:17.560Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}