Merge pull request #2758 from bmiklautz/fix/CreateProcess

CreateProcess misc fixes
This commit is contained in:
Hardening 2015-07-02 13:11:06 +02:00
commit 87c5377f42
1 changed files with 6 additions and 5 deletions

View File

@ -241,7 +241,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
else
{
lpszEnvironmentBlock = GetEnvironmentStrings();
if (lpszEnvironmentBlock)
if (!lpszEnvironmentBlock)
goto finish;
envp = EnvironmentBlockToEnvpA(lpszEnvironmentBlock);
}
@ -279,7 +279,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
/* set default signal handlers */
memset(&act, 0, sizeof(act));
act.sa_sigaction = SIG_DFL;
act.sa_handler = SIG_DFL;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
for (sig = 1; sig < NSIG; sig++)
@ -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 */