Skip to content

Commit 4b47e97

Browse files
phatchmanalexrp
authored andcommitted
Return FileNotFound when CreateProcessW is called with a missing path (#23567)
1 parent d80cfa6 commit 4b47e97

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/std/os/windows.zig

+1
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@ pub fn CreateProcessW(
19131913
switch (GetLastError()) {
19141914
.FILE_NOT_FOUND => return error.FileNotFound,
19151915
.PATH_NOT_FOUND => return error.FileNotFound,
1916+
.DIRECTORY => return error.FileNotFound,
19161917
.ACCESS_DENIED => return error.AccessDenied,
19171918
.INVALID_PARAMETER => unreachable,
19181919
.INVALID_NAME => return error.InvalidName,

test/standalone/windows_spawn/main.zig

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub fn main() anyerror!void {
5151
try testExec(allocator, "HeLLo.exe", "hello from exe\n");
5252
// without extension should find the .exe (case insensitive)
5353
try testExec(allocator, "heLLo", "hello from exe\n");
54+
// with invalid cwd
55+
try std.testing.expectError(error.FileNotFound, testExecWithCwd(allocator, "hello.exe", "missing_dir", ""));
5456

5557
// now add a .bat
5658
try tmp.dir.writeFile(.{ .sub_path = "hello.bat", .data = "@echo hello from bat" });

0 commit comments

Comments
 (0)