diff options
author | Werner Koch <[email protected]> | 2021-03-08 20:26:16 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-03-08 20:53:28 +0000 |
commit | cf2f6d8a3f0594c03c383b4989a3041e9c4536d7 (patch) | |
tree | eb5fb20b10de6a389759734a651be26da1e0be8b /g10/exec.c | |
parent | scd: Fix for X448. (diff) | |
download | gnupg-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.c | 20 |
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; |