aboutsummaryrefslogtreecommitdiffstats
path: root/g10/exec.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-03-08 20:26:16 +0000
committerWerner Koch <[email protected]>2021-03-08 20:53:28 +0000
commitcf2f6d8a3f0594c03c383b4989a3041e9c4536d7 (patch)
treeeb5fb20b10de6a389759734a651be26da1e0be8b /g10/exec.c
parentscd: Fix for X448. (diff)
downloadgnupg-cf2f6d8a3f0594c03c383b4989a3041e9c4536d7.tar.gz
gnupg-cf2f6d8a3f0594c03c383b4989a3041e9c4536d7.zip
w32: Change spawn functions to use Unicode version of CreateProcess.
* common/exechelp-w32.c (gnupg_spawn_process): Change to use CreateProcessW. (gnupg_spawn_process_fd): Ditto. (gnupg_spawn_process_detached): Ditto. * g10/exec.c (w32_system): Ditto. -- GnuPG-bug-id: 4398 We do not use this weirdo CREATE_UNICODE_ENVIRONMENT flag because it does not make any sense to have non-ASCII names in the environment. I can't imagine why this should be used at all and rationale for this API features is, well, sparse.
Diffstat (limited to 'g10/exec.c')
-rw-r--r--g10/exec.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/g10/exec.c b/g10/exec.c
index f63904b39..f612c850a 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -107,28 +107,36 @@ w32_system(const char *command)
else
{
char *string;
+ wchar_t *wstring;
PROCESS_INFORMATION pi;
- STARTUPINFO si;
+ STARTUPINFOW si;
/* We must use a copy of the command as CreateProcess modifies
* this argument. */
string = xstrdup (command);
+ wstring = utf8_to_wchar (string);
+ xfree (string);
+ if (!wstring)
+ return -1;
memset (&pi, 0, sizeof(pi));
memset (&si, 0, sizeof(si));
si.cb = sizeof (si);
- if (!CreateProcess (NULL, string, NULL, NULL, FALSE,
- DETACHED_PROCESS,
- NULL, NULL, &si, &pi))
- return -1;
+ if (!CreateProcessW (NULL, wstring, NULL, NULL, FALSE,
+ DETACHED_PROCESS,
+ NULL, NULL, &si, &pi))
+ {
+ xfree (wstring);
+ return -1;
+ }
/* Wait for the child to exit */
WaitForSingleObject (pi.hProcess, INFINITE);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
- xfree (string);
+ xfree (wstring);
}
return 0;