Support non-ASCII TAP adapter names on Windows
PATCH 1/1 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.
--- src/openvpn/tun.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
src/openvpn/tun.c +10 -5
@@ -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 */
Signature · 1 line
1.7.9.5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
ACK on this; a local build checks out with all sorts of creative UTF-8 device names I threw at it, including ones with spaces too.
- --
Josh Cepek
src/openvpn/tun.c
Quoted 14 lines · Heiko Hund
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 <[email protected]...>--- src/openvpn/tun.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)src/openvpn/tun.c +0
-0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)
iQGcBAEBAgAGBQJSZtFAAAoJENcx2Xpgb9RjWeQL/RbLTXgI5i4cEVR5o3pa76Ov xp28gEyhDlmMDWGiMSKGePQknn3GfymzZ7SgtYnJKercZcqSSMvGefHIK71FQ1R0 D9N17K0KEnEOAEFOLZjBGFITqPVmeDX4mVqLKYh6xOGCeae0BltgpfawOcjUTJ/h /M6DsrkrSexizPWGa5mr4+kmxbWOJ0rbxeLNQT5neecibB7FWjQXDEpz74HwVMOU x6FxtAOenFU6XYfFhczK3G1xxyWP1NqZhmNPUiSydAjTvXepzLIPvGocZjfozd22 f/Eyf3MvZuFBF7Xu8QZe1UU+E0kf7ZgMjHwzpNwDhfu4Halc/9NCn4895D8xrAXA AyUfv3st1+UKdQNIHhyfXQLKP7vWFZYHS9hC3SN8G+wgeamyEP1WoFp1bimaCqhi jHC/n+5piDN2iOCGe5H11RF+kx+UVxgs7+zyY/VT6zNyLQVnmWl0ynynh/i1hiUo LsfooT2sRA4KCsGfRzEuEFtsMpqYKhqub+tH3JOYSw==
=xGRO
-----END PGP SIGNATURE-----
Thanks. Patch has been applied to the master and release/2.3 branch.
commit f2e40082349098d3c22981bf1e6d305826f1173f (master) commit 8f5a4598662f4b2abe7acfe8f68c90a8b03f2dc8 (release/2.3)
Author: Heiko Hund Date: Tue Oct 15 11:23:42 2013 +0200
Support non-ASCII TAP adapter names on Windows
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Josh Cepek <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7913
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering