{"record":{"id":"db0e4e1adbe25bc4","repo":"GitoxideLabs/gitoxide","slug":"number-of-commits-in-cdat-chunk-to-fit-in-32-bits","errorCode":null,"errorMessage":"number of commits in CDAT chunk to fit in 32 bits","messagePattern":"number of commits in CDAT chunk to fit in 32 bits","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-commitgraph/src/file/init.rs","lineNumber":99,"sourceCode":"                }\n                Ok(chunk_range.start)\n            })\n            .ok()\n            .transpose()?;\n\n        let (commit_data_offset, commit_data_count): (_, u32) = chunks\n            .validated_usize_offset_by_id(COMMIT_DATA_CHUNK_ID, |chunk_range| {\n                let chunk_size = chunk_range.len();\n\n                let entry_size = object_hash.len_in_bytes() + COMMIT_DATA_ENTRY_SIZE_SANS_HASH;\n                if chunk_size % entry_size != 0 {\n                    return Err(message!(\"Commit-graph chunk {COMMIT_DATA_CHUNK_ID:?} has invalid size: chunk size {chunk_size} is not a multiple of {entry_size}\").raise())\n                }\n                Ok((\n                    chunk_range.start,\n                    (chunk_size / entry_size)\n                        .try_into()\n                        .expect(\"number of commits in CDAT chunk to fit in 32 bits\"),\n                ))\n            })??;\n\n        let fan_offset = chunks\n            .validated_usize_offset_by_id(OID_FAN_CHUNK_ID, |chunk_range| {\n                let chunk_size = chunk_range.len();\n\n                let expected_size = 4 * FAN_LEN;\n                if chunk_size != expected_size {\n                    return Err(message!(\"Commit-graph chunk {OID_FAN_CHUNK_ID:?} has invalid size: expected chunk length {expected_size}, got {chunk_size}\").raise())\n                }\n                Ok(chunk_range.start)\n            })?\n            .or_raise(|| message(\"Error getting offset for OID fan chunk\"))?;\n\n        let (oid_lookup_offset, oid_lookup_count): (_, u32) = chunks\n            .validated_usize_offset_by_id(OID_LOOKUP_CHUNK_ID, |chunk_range| {\n                let chunk_size = chunk_range.len();","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-commitgraph/src/file/init.rs#L81-L117","documentation":"During commit-graph file initialization, the number of entries in the CDAT (commit data) chunk — chunk size divided by entry size — is cast to u32. Since the format stores commit counts in 32 bits and the chunk was size-validated beforehand, this conversion is expected to always fit. The panic indicates the chunk size is absurdly large, i.e. a corrupt or malicious commit-graph file.","triggerScenarios":"Calling `gix_commitgraph::File::at()` on a commit-graph whose CDAT chunk size / entry size exceeds u32::MAX — possible only with a corrupt or crafted file (or an internal validation bug).","commonSituations":"Truncated or corrupted commit-graph files, disk corruption, hand-edited files, fuzz inputs.","solutions":["Regenerate the commit-graph (`git commit-graph write`) or delete it","Treat commit-graph load failure as non-fatal in application code and fall back to raw object reads","If reproducible with a git-produced file, report upstream"],"exampleFix":"// before\nlet graph = gix_commitgraph::File::at(path, hash)?;\n// after\nlet graph = gix_commitgraph::File::at(path, hash).ok(); // graphs are optional caches","handlingStrategy":"fallback","validationCode":"let meta = std::fs::metadata(path)?; if meta.len() > u32::MAX as u64 { eprintln!(\"implausibly large commit-graph; skipping\"); }","typeGuard":null,"tryCatchPattern":"let graph = match gix_commitgraph::File::at(path, hash).map_err(|e| e.into_error()) { Ok(g) => Some(g), Err(e) => { log::warn!(\"commit-graph unusable: {e}\"); None } };","preventionTips":["Regenerate or delete corrupt commit-graph files promptly","Wrap commit-graph access in a helper that degrades gracefully","Run `git commit-graph verify` in maintenance scripts"],"tags":["rust","panic","commitgraph","corrupt-file","overflow"],"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"}