]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
set Windows environment variables as UCS-2
authorHeiko Hund <heiko.hund@sophos.com>
Wed, 7 Dec 2011 17:59:21 +0000 (18:59 +0100)
committerDavid Sommerseth <davids@redhat.com>
Sun, 5 Feb 2012 16:24:19 +0000 (17:24 +0100)
Windows uses 16 bit wide characters to represent Unicode in the
process environment. Convert UTF-8 to UCS-2 and use the wide
character API to set environment variables.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
misc.c

diff --git a/misc.c b/misc.c
index 884f2b22ddc26e9840ef1cfb73a2ef2c89898753..1aa1be471c16111f7953889a93d41f2966f2ecd0 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1082,8 +1082,8 @@ setenv_str_ex (struct env_set *es,
     {
 #if defined(WIN32)
       {
-       /*msg (M_INFO, "SetEnvironmentVariable '%s' '%s'", name_tmp, val_tmp ? val_tmp : "NULL");*/
-       if (!SetEnvironmentVariable (name_tmp, val_tmp))
+        if (!SetEnvironmentVariableW (wide_string (name_tmp, &gc),
+                                      wide_string (val_tmp, &gc)))
          msg (M_WARN | M_ERRNO, "SetEnvironmentVariable failed, name='%s', value='%s'",
               name_tmp,
               val_tmp ? val_tmp : "NULL");