{"record":{"id":"06bc1c4a77868981","repo":"GitoxideLabs/gitoxide","slug":"integer-overflow","errorCode":null,"errorMessage":"Integer overflow","messagePattern":"Integer overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-config/src/file/access/comfort.rs","lineNumber":186,"sourceCode":"        self.integer_filter_by(key.section_name, key.subsection_name, key.value_name, filter)\n    }\n\n    /// Like [`integer_by()`](File::integer_by()), but the section containing the returned value must pass `filter` as well.\n    pub fn integer_filter_by(\n        &self,\n        section_name: impl AsRef<str>,\n        subsection_name: impl AsBStrOpt,\n        value_name: impl AsRef<str>,\n        filter: impl FnMut(&Metadata) -> bool,\n    ) -> Result<Option<i64>, value::Error> {\n        let Some(int) = self\n            .raw_value_filter_by(section_name, subsection_name, value_name, filter)\n            .ok()\n        else {\n            return Ok(None);\n        };\n        crate::Integer::try_from(BStr::new(&int))\n            .and_then(|b| b.to_decimal().ok_or_else(|| value::Error::new(\"Integer overflow\", int)))\n            .map(Some)\n    }\n\n    /// Like [`strings_by()`](File::strings_by()), but suitable for statically known `key`s like `remote.origin.url`.\n    pub fn strings(&self, key: impl AsKey) -> Option<Vec<BString>> {\n        let key = key.try_as_key()?;\n        self.strings_by(key.section_name, key.subsection_name, key.value_name)\n    }\n\n    /// Similar to [`values_by(…)`](File::values_by()) but returning strings if at least one of them was found.\n    pub fn strings_by(\n        &self,\n        section_name: impl AsRef<str>,\n        subsection_name: impl AsBStrOpt,\n        value_name: impl AsRef<str>,\n    ) -> Option<Vec<BString>> {\n        self.raw_values_by(section_name, subsection_name, value_name).ok()\n    }","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-config/src/file/access/comfort.rs#L168-L204","documentation":"`File::integer_filter_by()` successfully parsed the raw config value into a gix-config `Integer`, but `to_decimal()` — which converts the value with its unit multiplier into a plain decimal — failed, meaning the value overflows the target integer type (e.g. '10g' scaled beyond i64 range). The code raises a value::Error 'Integer overflow' carrying the original bytes.","triggerScenarios":"Calling `file.integer(key)` / `integer_filter_by(...)` where the stored value with its k/m/g suffix, after multiplication, exceeds the numeric range, e.g. `size = 18446744073709551616` or a huge 'g'-suffixed value.","commonSituations":"Users copying 64-bit-plus byte counts into config keys like `core.bigFileThreshold` or `pack.packSizeLimit`, or config written by other tools expecting unsigned 128-bit semantics.","solutions":["Reduce the value or use a larger suffix-appropriate magnitude that fits in the target signed type","Use the raw `Integer` and inspect it yourself instead of demanding a decimal","Catch the value::Error and fall back to a sensible default"],"exampleFix":"// before (config)\n[pack]\n    windowMemory = 18446744073709551615\n// after\n[pack]\n    windowMemory = 4g","handlingStrategy":"try-catch","validationCode":"fn fits_decimal(s: &BStr) -> bool {\n    Integer::try_from(s).ok().and_then(|i| i.to_decimal()).is_some()\n}","typeGuard":null,"tryCatchPattern":"match file.integer(key) {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"Integer overflow\") => DEFAULT_VALUE,\n    Err(e) => return Err(e),\n}","preventionTips":["Keep byte-count config values well below i64::MAX after suffix scaling","Prefer explicit small suffixes (k/m) for large values","Test config parsing against extreme values in CI"],"tags":["git","config","overflow","integer"],"backgroundTag":"value-out-of-range","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"}