core,w32: Fix new w32-util functions
authorAndre Heinecke <aheinecke@gnupg.org>
Tue, 9 Apr 2019 12:11:21 +0000 (14:11 +0200)
committerAndre Heinecke <aheinecke@gnupg.org>
Tue, 9 Apr 2019 12:11:21 +0000 (14:11 +0200)
* src/w32-util.c (_gpgme_access): Respect mode parameter.
(_gpgme_create_process_utf8): Convert startupinfo, too.

--
This both did not show up in testing as we only use
mode F_OK and STARTUPINFOA is basically the same as
STARTUPINFOW.

Fixes commit: a82e3a0ae57a48ba173e282a050680751006c074

GnuPG-Bug-Id: T4453

src/w32-util.c

index eced139..6aa45f8 100644 (file)
@@ -832,12 +832,13 @@ int
 _gpgme_access (const char *path, int mode)
 {
   wchar_t *u16 = utf8_to_wchar0 (path);
-  int r = _waccess (u16, F_OK);
+  int r = _waccess (u16, mode);
 
   free(u16);
   return r;
 }
 
+
 /* Like CreateProcessA but mapping the arguments to wchar API */
 int _gpgme_create_process_utf8 (const char *application_name_utf8,
                                 char *command_line_utf8,
@@ -847,7 +848,7 @@ int _gpgme_create_process_utf8 (const char *application_name_utf8,
                                 DWORD dwCreationFlags,
                                 void *lpEnvironment,
                                 char *working_directory_utf8,
-                                LPSTARTUPINFOA lpStartupInfo,
+                                LPSTARTUPINFOA si,
                                 LPPROCESS_INFORMATION lpProcessInformation)
 {
   BOOL ret;
@@ -855,6 +856,27 @@ int _gpgme_create_process_utf8 (const char *application_name_utf8,
   wchar_t *command_line = utf8_to_wchar0 (command_line_utf8);
   wchar_t *working_directory = utf8_to_wchar0 (working_directory_utf8);
 
+  STARTUPINFOW siw;
+  memset (&siw, 0, sizeof siw);
+  if (si)
+    {
+      siw.cb = sizeof (siw);
+      siw.dwFlags = si->dwFlags;
+      siw.wShowWindow = si->wShowWindow;
+      siw.hStdInput = si->hStdInput;
+      siw.hStdOutput = si->hStdOutput;
+      siw.hStdError = si->hStdError;
+      siw.dwX = si->dwX;
+      siw.dwY = si->dwY;
+      siw.dwXSize = si->dwXSize;
+      siw.dwYSize = si->dwYSize;
+      siw.dwXCountChars = si->dwXCountChars;
+      siw.dwYCountChars = si->dwYCountChars;
+      siw.dwFillAttribute = si->dwFillAttribute;
+      siw.lpDesktop = utf8_to_wchar0 (si->lpDesktop);
+      siw.lpTitle = utf8_to_wchar0 (si->lpTitle);
+    }
+
   ret = CreateProcessW (application_name,
                         command_line,
                         lpProcessAttributes,
@@ -863,7 +885,7 @@ int _gpgme_create_process_utf8 (const char *application_name_utf8,
                         dwCreationFlags,
                         lpEnvironment,
                         working_directory,
-                        lpStartupInfo,
+                        si ? &siw : NULL,
                         lpProcessInformation);
   free (application_name);
   free (command_line);