commit ae38fc6a50dfcece964d7d19d9e35ac5dc583daa (tree)
parent 530228d9531e8d1dcf7e8ed88e68403e65bcf6bb
Author: phatchman <phatchman@users.noreply.github.com>
Date: Wed, 16 Apr 2025 07:39:44 +1000
Return FileNotFound when CreateProcessW is called with a missing path (#23567)
Diffstat:
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig
@@ -1980,6 +1980,7 @@ pub fn CreateProcessW(
switch (GetLastError()) {
.FILE_NOT_FOUND => return error.FileNotFound,
.PATH_NOT_FOUND => return error.FileNotFound,
+ .DIRECTORY => return error.FileNotFound,
.ACCESS_DENIED => return error.AccessDenied,
.INVALID_PARAMETER => unreachable,
.INVALID_NAME => return error.InvalidName,
diff --git a/test/standalone/windows_spawn/main.zig b/test/standalone/windows_spawn/main.zig
@@ -51,6 +51,8 @@ pub fn main() anyerror!void {
try testExec(allocator, "HeLLo.exe", "hello from exe\n");
// without extension should find the .exe (case insensitive)
try testExec(allocator, "heLLo", "hello from exe\n");
+ // with invalid cwd
+ try std.testing.expectError(error.FileNotFound, testExecWithCwd(allocator, "hello.exe", "missing_dir", ""));
// now add a .bat
try tmp.dir.writeFile(.{ .sub_path = "hello.bat", .data = "@echo hello from bat" });