]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fixed bug in automatic Win32 PATH setting code.
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sat, 17 Dec 2005 22:23:28 +0000 (22:23 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sat, 17 Dec 2005 22:23:28 +0000 (22:23 +0000)
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@856 e7ae566f-a301-0410-adde-c780ea21d3b5

misc.c

diff --git a/misc.c b/misc.c
index 61842081316c33a71dc7918ff7157981c74cea41..b7eaae9b4a5a716603a26712dee848ad36491da7 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1465,19 +1465,31 @@ configure_path (void)
   fp = fopen ("c:\\windows\\system32\\route.exe", "rb");
   if (fp)
     {
-      const int bufsiz = 512;
+      const int bufsiz = 4096;
       struct gc_arena gc = gc_new ();
       struct buffer oldpath = alloc_buf_gc (bufsiz, &gc);
       struct buffer newpath = alloc_buf_gc (bufsiz, &gc);
+      const char* delim = ";";
       DWORD status;
       fclose (fp);
       status = GetEnvironmentVariable ("PATH", BPTR(&oldpath), (DWORD)BCAP(&oldpath));
-      if (status > 0)
+#if 0
+      status = 0;
+#endif
+      if (!status)
        {
-         buf_printf (&newpath, "C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;%s", BSTR(&oldpath));
-         SetEnvironmentVariable ("PATH", BSTR(&newpath));
-         /*printf ("PATH: %s\n", BSTR(&newpath));*/
+         *BPTR(&oldpath) = '\0';
+         delim = "";
        }
+      buf_printf (&newpath, "C:\\WINDOWS\\System32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem%s%s",
+                 delim,
+                 BSTR(&oldpath));
+      SetEnvironmentVariable ("PATH", BSTR(&newpath));
+#if 0
+      status = GetEnvironmentVariable ("PATH", BPTR(&oldpath), (DWORD)BCAP(&oldpath));
+      if (status > 0)
+       printf ("PATH: %s\n", BSTR(&oldpath));
+#endif
       gc_free (&gc);
     }
 #endif