1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

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.
This commit is contained in:
Werner Koch 2021-03-08 21:26:16 +01:00
parent fc99f77b14
commit cf2f6d8a3f
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 111 additions and 53 deletions

View file

@ -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;