From be53e9e02924ff63dc57e1d2644f137f3d5b07ac Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Thu, 2 Jul 2015 12:05:46 +0200 Subject: [PATCH 1/2] 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. --- winpr/libwinpr/thread/process.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c index 475b14c8b..fca03dd2f 100644 --- a/winpr/libwinpr/thread/process.c +++ b/winpr/libwinpr/thread/process.c @@ -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 */ From c7adb569ffc53bbd242ea6bd6c32ec78879ed8b8 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Thu, 2 Jul 2015 12:25:48 +0200 Subject: [PATCH 2/2] CreateProcess: fix setting of default handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If SA_SIGINFO isn't set in the flags sa_handler is used instead of sa_sigaction. This fixes also the compiler warning: FreeRDP/winpr/libwinpr/thread/process.c: In function ‘_CreateProcessExA’: FreeRDP/winpr/libwinpr/thread/process.c:282:20: warning: assignment from incompatible pointer type [enabled by default] --- winpr/libwinpr/thread/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c index fca03dd2f..4dca0f4d0 100644 --- a/winpr/libwinpr/thread/process.c +++ b/winpr/libwinpr/thread/process.c @@ -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++)