{"record":{"id":"c483d35f2d853744","repo":"zed-industries/zed","slug":"invalid-argument-path-or-argument-contains-null-b","errorCode":null,"errorMessage":"invalid argument: path or argument contains null byte","messagePattern":"invalid argument: path or argument contains null byte","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/util/src/command/darwin.rs","lineNumber":566,"sourceCode":"    };\n    if fd == -1 {\n        return Err(io::Error::last_os_error());\n    }\n    Ok(unsafe { std::fs::File::from_raw_fd(fd) })\n}\n\n/// Zero means `Ok()`, all other values are treated as raw OS errors. Does not look at `errno`.\n/// Mirrored after Rust's std `cvt_nz` function.\nfn cvt_nz(error: libc::c_int) -> io::Result<()> {\n    if error == 0 {\n        Ok(())\n    } else {\n        Err(io::Error::from_raw_os_error(error))\n    }\n}\n\nfn invalid_input_error() -> io::Error {\n    io::Error::new(\n        io::ErrorKind::InvalidInput,\n        \"invalid argument: path or argument contains null byte\",\n    )\n}\n\n#[cfg(test)]\nmod tests {\n    use std::os::unix::process::ExitStatusExt as _;\n\n    use super::*;\n    use futures_lite::AsyncWriteExt;\n\n    // Verifies that pipes returned by `create_pipe` aren't visible to unrelated\n    // child processes spawned via `std::process::Command`. On macOS, `std`\n    // uses `posix_spawn` without `POSIX_SPAWN_CLOEXEC_DEFAULT`, so any\n    // non-CLOEXEC fd in the parent leaks into the child. Without\n    // `FD_CLOEXEC` on our pipe fds, an unrelated spawn (a terminal, the crash\n    // handler, etc.) running concurrently with a piped git child would hold","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/util/src/command/darwin.rs#L548-L584","documentation":"Sentinel io::Error (InvalidInput) raised by invalid_input_error and returned by spawn_posix_spawn when the program path or any argument contains a NUL byte. POSIX exec APIs are NUL-terminated C strings, so such a command can never be spawned.","triggerScenarios":"Thrown at crates/util/src/command/darwin.rs:566 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find where the null byte enters the path or argument (usually corrupted input or bad string truncation)","Sanitize or reject arguments containing interior NUL bytes before spawning","Log the offending command to locate the source of the embedded null"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}