CreateProcess: two fixes

* change to lpCurrentDirectory if set even if no token was supplied
* fix wrong check - add missing !

This was part of akallabeth's PR #2714.
This commit is contained in:
Bernhard Miklautz 2015-07-02 12:05:46 +02:00
parent fedd59816b
commit be53e9e029

View File

@ -241,7 +241,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
else
{
lpszEnvironmentBlock = GetEnvironmentStrings();
if (lpszEnvironmentBlock)
if (!lpszEnvironmentBlock)
goto finish;
envp = EnvironmentBlockToEnvpA(lpszEnvironmentBlock);
}
@ -317,11 +317,12 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
if (token->UserId)
setuid((uid_t) token->UserId);
/* TODO: add better cwd handling and error checking */
if (lpCurrentDirectory && strlen(lpCurrentDirectory) > 0)
chdir(lpCurrentDirectory);
}
/* TODO: add better cwd handling and error checking */
if (lpCurrentDirectory && strlen(lpCurrentDirectory) > 0)
chdir(lpCurrentDirectory);
if (execve(filename, pArgs, envp) < 0)
{
/* execve failed - end the process */