Return FileNotFound when CreateProcessW is called with a missing path (#23567)

This commit is contained in:
phatchman 2025-04-16 07:39:44 +10:00 committed by Alex Rønne Petersen
parent d80cfa6f41
commit 4b47e978e3
No known key found for this signature in database
2 changed files with 3 additions and 0 deletions

View File

@ -1913,6 +1913,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,

View File

@ -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" });