{"record":{"id":"824f886d7cdbda7f","repo":"uutils/coreutils","slug":"outofmemory","errorCode":"OutOfMemory","errorMessage":"formatting width too large","messagePattern":"formatting width too large","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/uucore/src/lib/features/format/mod.rs","lineNumber":182,"sourceCode":"                \"digits\" => String::from_utf8_lossy(digits)\n            ),\n            Self::InvalidEncoding(no) => return no.fmt(f),\n        };\n        f.write_str(&message)\n    }\n}\n\n/// Maximum width for formatting to prevent memory allocation panics.\n/// Rust's formatter will panic when trying to allocate memory for very large widths.\n/// This limit is somewhat arbitrary but should be well above any practical use case\n/// while still preventing formatter panics.\nconst MAX_FORMAT_WIDTH: usize = 1_000_000;\n\n/// Check if a width is too large for formatting.\n/// Returns an error if the width exceeds MAX_FORMAT_WIDTH.\nfn check_width(width: usize) -> std::io::Result<()> {\n    if width > MAX_FORMAT_WIDTH {\n        Err(std::io::Error::new(\n            std::io::ErrorKind::OutOfMemory,\n            \"formatting width too large\",\n        ))\n    } else {\n        Ok(())\n    }\n}\n\n/// Reject a precision larger than printf/C allows (`i32::MAX`).\n///\n/// A precision near `usize::MAX` would otherwise overflow the precision/exponent\n/// arithmetic in the float formatters, so we cap it the way C `printf` does.\npub(crate) fn check_precision(precision: usize) -> Result<(), FormatError> {\n    if precision > i32::MAX as usize {\n        Err(FormatError::InvalidPrecision(precision.to_string()))\n    } else {\n        Ok(())\n    }","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/uutils/coreutils/blob/85295bbf788bfd7a6926ba692031563504b304b7/src/uucore/src/lib/features/format/mod.rs#L164-L200","documentation":"Error \"formatting width too large\" thrown in uutils/coreutils.","triggerScenarios":"Occurs when a printf-style format width specifier exceeds the maximum supported value.","commonSituations":"Using an extremely large field width like `printf '%999999999999d'` or a width derived from untrusted input.","solutions":["Reduce the field width/precision in the format specification to a reasonable value.","Validate user-supplied width arguments against a sane upper bound before formatting."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"85295bbf788bfd7a6926ba692031563504b304b7","analyzedAt":"2026-08-19T21:43:27.871Z","contentChangedAt":"2026-08-19T21:43:27.871Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}