Skip to content

Commit 69ba984

Browse files
slipherillwieckz
authored andcommitted
Windows: block NaCl process from inheriting environment
When creating a NaCl (or native exe) VM on Windows, block evironment variables from being passed through to the subprocess as is done on *nix. Probably we do this since there are NACL* variables that can disable secure sandboxing. inheritEnvironment is always false on Windows, but I implemented the true case anyway since it's less code than having the Q_UNUSED and asserting it's false.
1 parent 063cf65 commit 69ba984

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/engine/framework/VirtualMachine.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@ static std::pair<Sys::OSHandle, IPC::Socket> InternalLoadModule(std::pair<IPC::S
293293
startupInfo.hStdError = stderrRedirectHandle;
294294
startupInfo.dwFlags = STARTF_USESTDHANDLES;
295295
}
296+
char emptyEnvironment[] = {'\0', '\0'};
296297
startupInfo.cb = sizeof(startupInfo);
297-
if (!CreateProcessW(nullptr, &wcmdline[0], nullptr, nullptr, TRUE, CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB | CREATE_NO_WINDOW, nullptr, nullptr, &startupInfo, &processInfo)) {
298+
if (!CreateProcessW(nullptr, &wcmdline[0], nullptr, nullptr,
299+
TRUE, CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB | CREATE_NO_WINDOW,
300+
inheritEnvironment ? nullptr : emptyEnvironment,
301+
nullptr, &startupInfo, &processInfo)) {
298302
CloseHandle(job);
299303
Sys::Drop("VM: Could not create child process: %s", Sys::Win32StrError(GetLastError()));
300304
}
@@ -314,7 +318,6 @@ static std::pair<Sys::OSHandle, IPC::Socket> InternalLoadModule(std::pair<IPC::S
314318
if (reserve_mem)
315319
VirtualAllocEx(processInfo.hProcess, nullptr, 1 << 30, MEM_RESERVE, PAGE_NOACCESS);
316320
#endif
317-
Q_UNUSED(inheritEnvironment);
318321

319322
ResumeThread(processInfo.hThread);
320323
CloseHandle(processInfo.hThread);

0 commit comments

Comments
 (0)