From a67724cb6dc227a781b76d5c7baaaeacbf395f01 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 17 Dec 2005 22:23:28 +0000 Subject: Fixed bug in automatic Win32 PATH setting code. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@856 e7ae566f-a301-0410-adde-c780ea21d3b5 --- misc.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/misc.c b/misc.c index 6184208..b7eaae9 100644 --- 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 -- cgit v1.2.3