diff options
author | Heiko Hund <heiko.hund@sophos.com> | 2013-10-15 11:23:42 +0200 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2013-10-23 19:36:57 +0200 |
commit | f2e40082349098d3c22981bf1e6d305826f1173f (patch) | |
tree | e5cfc81a7fc3027ee60091bbab6ce12a218f3473 /src/openvpn/tun.c | |
parent | 30e358e5de352c8de04a955dc89f33e1710e9b97 (diff) | |
download | openvpn-f2e40082349098d3c22981bf1e6d305826f1173f.tar.gz openvpn-f2e40082349098d3c22981bf1e6d305826f1173f.tar.xz openvpn-f2e40082349098d3c22981bf1e6d305826f1173f.zip |
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>
Diffstat (limited to 'src/openvpn/tun.c')
-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 86a43f2..9f53b23 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3141,9 +3141,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( @@ -3177,12 +3177,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) @@ -3190,10 +3190,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 */ |