{"record":{"id":"bd4c1a76746aff8d","repo":"GitoxideLabs/gitoxide","slug":"ofs-delta-base-distance-base-distance-is-invalid","errorCode":null,"errorMessage":"OFS_DELTA base distance {base_distance} is invalid for pack offset {pack_offset}","messagePattern":"OFS_DELTA base distance (.+?) is invalid for pack offset (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-pack/src/cache/delta/from_offsets.rs","lineNumber":110,"sourceCode":"\n            use crate::data::entry::Header::*;\n            match entry.header {\n                Tree | Blob | Commit | Tag => {\n                    tree.add_root(pack_offset, data)?;\n                }\n                RefDelta { base_id } => {\n                    resolve_in_pack_id(base_id.as_ref())\n                        .ok_or(Error::UnresolvedRefDelta { id: base_id })\n                        .and_then(|base_pack_offset| {\n                            tree.add_child(base_pack_offset, pack_offset, data).map_err(Into::into)\n                        })?;\n                }\n                OfsDelta { base_distance } => {\n                    let Some(base_pack_offset) =\n                        crate::data::entry::Header::verified_base_pack_offset(pack_offset, base_distance)\n                    else {\n                        return Err(Error::Io {\n                            source: io::Error::new(\n                                io::ErrorKind::InvalidData,\n                                format!(\n                                    \"OFS_DELTA base distance {base_distance} is invalid for pack offset {pack_offset}\"\n                                ),\n                            ),\n                            message: \"invalid OFS_DELTA base distance\",\n                        });\n                    };\n                    tree.add_child(base_pack_offset, pack_offset, data)?;\n                }\n            }\n            progress.inc();\n            if idx % 10_000 == 0 && should_interrupt.load(Ordering::SeqCst) {\n                return Err(Error::Interrupted);\n            }\n        }\n\n        progress.show_throughput(then);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/cache/delta/from_offsets.rs#L92-L128","documentation":"When resolving pack entries by offset, gix-pack validates each OFS_DELTA entry: the base distance must resolve to a valid base pack offset relative to the delta's own offset (`Header::verified_base_pack_offset`). If verification fails, the data is structurally inconsistent and iteration aborts with an `InvalidData` io error wrapped as `Error::Io` with the message 'invalid OFS_DELTA base distance'.","triggerScenarios":"Iterating entries via `gix_pack::data::File::stream_from`/offset iteration (from_offsets) over a pack containing an OFS_DELTA whose encoded distance points before the start of the pack or is otherwise impossible.","commonSituations":"Corrupted or truncated packfiles on disk; manually edited or fuzzed pack data; reading bytes at a wrong offset so a delta header is misparsed.","solutions":["Verify the pack's integrity (trailer SHA/checksum) and re-fetch or re-clone the repository if it fails.","Run `gix pack` verify/index operations on the pack to locate the corrupt entry.","If handling untrusted packs, catch the error and reject the pack instead of panicking or proceeding."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match pack_file::iter::FromOffsets::new(...) {\n    Err(e) => /* reject the pack: check e for 'invalid OFS_DELTA base distance' and verify the pack checksum */,\n    ok => /* proceed */,\n}","preventionTips":["Verify pack checksums before delta iteration.","Re-fetch or regenerate packs that fail structural validation.","Never iterate raw pack bytes at hand-computed offsets; use the crate's parsed headers."],"tags":["git","packfile","corruption","delta","rust"],"backgroundTag":"invalid-pack-data","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"}