astrid-runtime/astrid · error

mount path overflow

Error message

mount path overflow

What it means

This InvalidData error guards the octal-escape decoder used to reconstruct mount path names. Before reading a 4-byte escape sequence it computes index+4 (and index+1) with checked arithmetic; on overflow it fails with 'mount path overflow' instead of wrapping. It also fires when a non-escape byte cannot advance the index by 1 without overflow.

Solutions

  1. Check the length of the encoded path input before decoding and reject absurdly long values
  2. Ensure the caller passes a real filesystem path string, not arbitrary untrusted blobs
  3. On 32-bit targets, run validation on 64-bit or bound inputs to < usize::MAX/4 bytes
  4. If triggered by corrupt state, regenerate or repair the stored mount-path record

Example fix

// before
let decoded = decode_mount_path(untrusted_blob)?;
// after
if untrusted_blob.len() > 4096 { return Err(...) }
let decoded = decode_mount_path(untrusted_blob)?;
Defensive patterns

Strategy: validation

Validate before calling

fn sane_len(s: &str) -> bool { s.len() < 4096 }
// call only if sane_len(encoded_path)

Try / catch

match decode_result {
    Err(e) if e.to_string().contains("mount path overflow") => eprintln!("input too large/corrupt"),
    other => other?,
}

Prevention

When it happens

Trigger: Decoding an encoded mount path whose byte index arithmetic would overflow usize — practically only on paths of astronomic length or on malformed index handling during decode_mount_path-style checks.

Common situations: Extremely large or corrupted encoded path strings passed to mount-path verification; adversarial input in a path-encoding field; 16-bit/32-bit platforms with tiny usize.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/d6694b37a0ce3799. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-kernel/src/lib.rs:4409

    std::fs::File::open(path)?.sync_all()
}

#[cfg(target_os = "linux")]
fn audit_mountpoint(path: &Path) -> std::io::Result<bool> {
    use std::os::unix::ffi::OsStringExt as _;

    let canonical = std::fs::canonicalize(path)?;
    let mountinfo = std::fs::read_to_string("/proc/self/mountinfo")?;
    for line in mountinfo.lines() {
        let Some(encoded) = line.split_whitespace().nth(4) else {
            continue;
        };
        let mut decoded = Vec::with_capacity(encoded.len());
        let bytes = encoded.as_bytes();
        let mut index = 0;
        while index < bytes.len() {
            let escape_end = index.checked_add(4).ok_or_else(|| {
                std::io::Error::new(std::io::ErrorKind::InvalidData, "mount path overflow")
            })?;
            let escape_start = index.checked_add(1).ok_or_else(|| {
                std::io::Error::new(std::io::ErrorKind::InvalidData, "mount path overflow")
            })?;
            if bytes[index] == b'\\' && escape_end <= bytes.len() {
                let digits = bytes.get(escape_start..escape_end).ok_or_else(|| {
                    std::io::Error::new(std::io::ErrorKind::InvalidData, "invalid mount escape")
                })?;
                if digits.iter().all(|digit| (b'0'..=b'7').contains(digit)) {
                    let value = u8::from_str_radix(
                        std::str::from_utf8(digits).map_err(std::io::Error::other)?,
                        8,
                    )
                    .map_err(std::io::Error::other)?;
                    decoded.push(value);
                    index = escape_end;
                    continue;
                }

View on GitHub (pinned to affd8760f4)