Module: wine Branch: refs/heads/master Commit: 61c3bb03a0daa16599db5afffd3a8f8fabaadccc URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=61c3bb03a0daa16599db5aff...
Author: James Hawkins truiken@gmail.com Date: Sun Mar 26 21:53:09 2006 -0600
kernel: Error out of CreateProcess if the specified current directory doesn't exist.
---
dlls/kernel/process.c | 6 +++++- dlls/kernel/tests/process.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c index d1ff341..4263a22 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -1661,7 +1661,11 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_
if (cur_dir) { - unixdir = wine_get_unix_file_name( cur_dir ); + if (!(unixdir = wine_get_unix_file_name( cur_dir ))) + { + SetLastError(ERROR_DIRECTORY); + goto done; + } } else { diff --git a/dlls/kernel/tests/process.c b/dlls/kernel/tests/process.c index b28f28d..245136f 100644 --- a/dlls/kernel/tests/process.c +++ b/dlls/kernel/tests/process.c @@ -811,6 +811,18 @@ static void test_Directory(void) okChildIString("Misc", "CurrDirA", windir); release_memory(); assert(DeleteFileA(resfile) != 0); + + /* search PATH for the exe if directory is NULL */ + ok(CreateProcessA(NULL, "winver.exe", NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); + ok(TerminateProcess(info.hProcess, 0), "Child process termination\n"); + + /* if any directory is provided, don't search PATH, error on bad directory */ + SetLastError(0xdeadbeef); + memset(&info, 0, sizeof(info)); + ok(!CreateProcessA(NULL, "winver.exe", NULL, NULL, FALSE, 0L, + NULL, "non\existent\directory", &startup, &info), "CreateProcess\n"); + ok(GetLastError() == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %ld\n", GetLastError()); + ok(!TerminateProcess(info.hProcess, 0), "Child process should not exist\n"); }
static BOOL is_str_env_drive_dir(const char* str)