kernel32/tests: Quote command line arguments that might contain spaces.

This commit is contained in:
Greg Geldorp 2010-12-21 16:41:24 +01:00 committed by Alexandre Julliard
parent 59398d7ca7
commit a4a73c20af
2 changed files with 28 additions and 28 deletions

View File

@ -282,15 +282,15 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
get_file_name(dbglog);
get_events(dbglog, &start_event, &done_event);
cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+10+strlen(dbgtasks)+1+strlen(dbglog)+34+1);
sprintf(cmd, "%s debugger %s %s %%ld %%ld", argv0, dbgtasks, dbglog);
cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+10+strlen(dbgtasks)+1+strlen(dbglog)+2+34+1);
sprintf(cmd, "%s debugger %s \"%s\" %%ld %%ld", argv0, dbgtasks, dbglog);
ret=RegSetValueExA(hkey, "debugger", 0, REG_SZ, (BYTE*)cmd, strlen(cmd)+1);
ok(ret == ERROR_SUCCESS, "unable to set AeDebug/debugger: ret=%d\n", ret);
HeapFree(GetProcessHeap(), 0, cmd);
get_file_name(childlog);
cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+16+strlen(dbglog)+1);
sprintf(cmd, "%s debugger crash %s", argv0, childlog);
cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+16+strlen(dbglog)+2+1);
sprintf(cmd, "%s debugger crash \"%s\"", argv0, childlog);
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
@ -582,8 +582,8 @@ static void test_debug_loop(int argc, char **argv)
ok(!ret, "DebugActiveProcess() succeeded on own process.\n");
get_file_name(blackbox_file);
cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv[0]) + strlen(arguments) + strlen(blackbox_file) + 10);
sprintf(cmd, "%s%s%08x %s", argv[0], arguments, pid, blackbox_file);
cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv[0]) + strlen(arguments) + strlen(blackbox_file) + 2 + 10);
sprintf(cmd, "%s%s%08x \"%s\"", argv[0], arguments, pid, blackbox_file);
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);

View File

@ -541,7 +541,7 @@ static void test_Startup(void)
startup.wShowWindow = SW_SHOWNORMAL;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -579,7 +579,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -617,7 +617,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -655,7 +655,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -693,7 +693,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -733,7 +733,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -771,7 +771,7 @@ static void test_Startup(void)
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -811,7 +811,7 @@ static void test_CommandLine(void)
/* the basics */
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\" \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -832,7 +832,7 @@ static void test_CommandLine(void)
/* from Frangois */
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -851,7 +851,7 @@ static void test_CommandLine(void)
/* Test for Bug1330 to show that XP doesn't change '/' to '\\' in argv[0]*/
get_file_name(resfile);
/* Use exename to avoid buffer containing things like 'C:' */
sprintf(buffer, "./%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", exename, resfile);
sprintf(buffer, "./%s tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
SetLastError(0xdeadbeef);
ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
@ -866,7 +866,7 @@ static void test_CommandLine(void)
get_file_name(resfile);
/* Use exename to avoid buffer containing things like 'C:' */
sprintf(buffer, ".\\%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", exename, resfile);
sprintf(buffer, ".\\%s tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
SetLastError(0xdeadbeef);
ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
@ -885,8 +885,8 @@ static void test_CommandLine(void)
*(lpFilePart -1 ) = 0;
p = strrchr(fullpath, '\\');
/* Use exename to avoid buffer containing things like 'C:' */
if (p) sprintf(buffer, "..%s/%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", p, exename, resfile);
else sprintf(buffer, "./%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", exename, resfile);
if (p) sprintf(buffer, "..%s/%s tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", p, exename, resfile);
else sprintf(buffer, "./%s tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
SetLastError(0xdeadbeef);
ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
@ -909,7 +909,7 @@ static void test_CommandLine(void)
/* Use exename to avoid buffer containing things like 'C:' */
if (p) sprintf(buffer, "..%s/%s", p, exename);
else sprintf(buffer, "./%s", exename);
sprintf(buffer2, "dummy tests/process.c %s \"a\\\"b\\\\\" c\\\" d", resfile);
sprintf(buffer2, "dummy tests/process.c \"%s\" \"a\\\"b\\\\\" c\\\" d", resfile);
SetLastError(0xdeadbeef);
ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
@ -1007,7 +1007,7 @@ static void test_Directory(void)
/* the basics */
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
GetWindowsDirectoryA( windir, sizeof(windir) );
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, windir, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
@ -1113,7 +1113,7 @@ static void test_Environment(void)
/* the basics */
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
@ -1131,7 +1131,7 @@ static void test_Environment(void)
/* the basics */
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
child_env_len = 0;
ptr = GetEnvironmentStringsA();
@ -1198,7 +1198,7 @@ static void test_SuspendFlag(void)
startup.wShowWindow = SW_SHOWNORMAL;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startup, &info), "CreateProcess\n");
ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running\n");
@ -1248,7 +1248,7 @@ static void test_DebuggingFlag(void)
startup.wShowWindow = SW_SHOWNORMAL;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info), "CreateProcess\n");
/* get all startup events up to the entry point break exception */
@ -1346,7 +1346,7 @@ static void test_Console(void)
cpOut = GetConsoleOutputCP();
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s console", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\" console", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
@ -1460,7 +1460,7 @@ static void test_Console(void)
startup.hStdError = hChildOutInh;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s stdhandle", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\" stdhandle", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &startup, &info), "CreateProcess\n");
ok(CloseHandle(hChildInInh), "Closing handle\n");
ok(CloseHandle(hChildOutInh), "Closing handle\n");
@ -1497,7 +1497,7 @@ static void test_ExitCode(void)
startup.wShowWindow = SW_SHOWNORMAL;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s exit_code", selfname, resfile);
sprintf(buffer, "\"%s\" tests/process.c \"%s\" exit_code", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */