Skip to main content

MAX_CACHED_FILE_BYTES

Constant MAX_CACHED_FILE_BYTES 

Source
pub const MAX_CACHED_FILE_BYTES: u64 = _; // 8_388_608u64
Expand description

Maximum file size MtimeFileCache::get_or_parse reads before parsing.

Enforced twice: a cheap std::fs::Metadata::len pre-filter rejects an obviously oversized file before it is even opened, and crate::fs_probe::read_to_string_capped then bounds the actual read itself, so an oversized file (e.g. a crafted pnpm-workspace.yaml in a cloned repository) never reaches YamlLoader or any content-based guard like crate::check_yaml_nesting_depth/crate::check_yaml_expansion — those guards run on content already read into memory, so they cannot bound the read itself. The capped read is what actually closes the gap: the stat pre-filter alone would leave a TOCTOU window where a symlink swap or concurrent growth between the stat and the read could let an oversized file’s content through. 8 MiB matches crate::cache’s MAX_CACHEABLE_ENTRY_BYTES order of magnitude and is generous for a real config file (.cargo/config.toml, .npmrc, pnpm-workspace.yaml), which are typically a few KB.