{"record":{"id":"216b8de515525e9a","repo":"GitoxideLabs/gitoxide","slug":"entry-header-size-does-not-fit-into-u16","errorCode":null,"errorMessage":"entry header size does not fit into u16","messagePattern":"entry header size does not fit into u16","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-pack/src/data/entry/decode.rs","lineNumber":101,"sourceCode":"                r.read_exact(hash)?;\n                let delta = RefDelta {\n                    base_id: gix_hash::ObjectId::from_bytes_or_panic(&hash[..]),\n                };\n                consumed += hash_len;\n                delta\n            }\n            BLOB => Blob,\n            TREE => Tree,\n            COMMIT => Commit,\n            TAG => Tag,\n            other => return Err(io::Error::other(format!(\"Object type {other} is unsupported\"))),\n        };\n        Ok(data::Entry {\n            header: object,\n            decompressed_size: size,\n            data_offset: pack_offset + consumed as u64,\n            encoded_header_size: encoded_header_size(consumed)\n                .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?,\n        })\n    }\n}\n\nfn encoded_header_size(consumed: usize) -> Result<u16, Error> {\n    consumed.try_into().map_err(|_| Error::Corrupt {\n        message: \"entry header size does not fit into u16\",\n    })\n}\n\n#[inline]\nfn streaming_parse_header_info(read: &mut dyn io::Read) -> Result<(u8, u64, usize), io::Error> {\n    let mut byte = [0u8; 1];\n    read.read_exact(&mut byte)?;\n    let mut c = byte[0];\n    let mut i = 1;\n    let type_id = (c >> 4) & 0b0000_0111;\n    let mut size = u64::from(c) & 0b0000_1111;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/data/entry/decode.rs#L83-L119","documentation":"When decoding a pack entry header, the number of bytes consumed by the header is stored as u16 (`encoded_header_size`). If the header consumed more than 65535 bytes, the try_into conversion fails with Error::Corrupt, surfaced as an io::Error of kind InvalidData with 'entry header size does not fit into u16'. This indicates a malformed or absurdly large pack entry header.","triggerScenarios":"Parsing a pack entry whose variable-length (LEB128-style) header spans more than u16::MAX bytes — only possible with a deliberately corrupt or crafted pack stream.","commonSituations":"Reading a maliciously crafted or bit-rotted pack file; fuzzing inputs; corrupted downloads.","solutions":["Re-obtain the pack file: re-clone or re-fetch the repository","Verify the pack with `gix pack verify` to confirm corruption","Check that the pack file was not modified in transit (compare checksums)","If it occurs during fuzz/testing, treat it as an expected rejection of invalid input"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate pack before parsing entries\ngix::pack::data::verify_integrity(pack_reader, progress, interrupt)\n    .map_err(|e| format!(\"pack corrupt: {e}\"))?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only parse packs obtained from trusted transports with checksum verification","Re-verify packs downloaded over unreliable networks","Treat header-size errors as input rejection in parsers/fuzz harnesses"],"tags":["pack","corruption","decode","git"],"backgroundTag":"internal-invariant-violation","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"}