diff options
author | Heiko Hund | 2013-10-15 11:23:42 +0200 |
---|---|---|
committer | Gert Doering | 2013-10-23 19:38:03 +0200 |
commit | 8f5a4598662f4b2abe7acfe8f68c90a8b03f2dc8 (patch) | |
tree | 9fe23db09bf3912d1fcaadf29c42b4af79e97ba6 /src | |
parent | 588c5fe795169c6b53e8e61f060714c1334b8e8e (diff) | |
download | openvpn-8f5a4598662f4b2abe7acfe8f68c90a8b03f2dc8.zip openvpn-8f5a4598662f4b2abe7acfe8f68c90a8b03f2dc8.tar.gz |
Support non-ASCII TAP adapter names on Windows
Currently the TAP adapter name is fetched as an OEM string, which
is problematic if it contains non-ASCII characters and is to used
with netsh. The logfile also contains these non UTF-8 characters.
This patch fetches the name from the registry as UCS-2 and converts
it right into UTF-8 before it's used.
Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Josh Cepek <josh.cepek@usa.net>
Message-Id: <1381829022-15244-1-git-send-email-heiko.hund@sophos.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7913
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f2e40082349098d3c22981bf1e6d305826f1173f)
Diffstat (limited to 'src')
-rw-r--r-- | src/openvpn/tun.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 047e585..d87d08f 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3058,9 +3058,9 @@ get_panel_reg (struct gc_arena *gc) char enum_name[256]; char connection_string[256]; HKEY connection_key; - char name_data[256]; + WCHAR name_data[256]; DWORD name_type; - const char name_string[] = "Name"; + const WCHAR name_string[] = L"Name"; len = sizeof (enum_name); status = RegEnumKeyEx( @@ -3094,12 +3094,12 @@ get_panel_reg (struct gc_arena *gc) else { len = sizeof (name_data); - status = RegQueryValueEx( + status = RegQueryValueExW( connection_key, name_string, NULL, &name_type, - name_data, + (LPBYTE) name_data, &len); if (status != ERROR_SUCCESS || name_type != REG_SZ) @@ -3107,10 +3107,15 @@ get_panel_reg (struct gc_arena *gc) NETWORK_CONNECTIONS_KEY, connection_string, name_string); else { + int n; + LPSTR name; struct panel_reg *reg; ALLOC_OBJ_CLEAR_GC (reg, struct panel_reg, gc); - reg->name = string_alloc (name_data, gc); + n = WideCharToMultiByte (CP_UTF8, 0, name_data, -1, NULL, 0, NULL, NULL); + name = gc_malloc (n, false, gc); + WideCharToMultiByte (CP_UTF8, 0, name_data, -1, name, n, NULL, NULL); + reg->name = name; reg->guid = string_alloc (enum_name, gc); /* link into return list */ |