Skip to content

Commit

Permalink
qga-win: network-get-interfaces command name field bug fix
Browse files Browse the repository at this point in the history
Network interface name is fetched as an encoded WCHAR array, (wide
character), then it is decoded using the guest's CP_ACP Windows code
page, which is the default code page as configure in the guest's
Windows, then it is returned as a byte array, (char array).

As stated in the BZ#1733165, when renaming a network interface to a
Chinese name and invoking this command, the returned name field has
the (\ufffd) value for each Chinese character the name had, this
value is an indication that the code page does not have the decoding
information for the given character.

This bug is a result of using the CP_ACP code page for decoding which
is an interchangeable code page, instead CP_UTF8 code page should be
used for decoding the network interface's name.

https://bugzilla.redhat.com/show_bug.cgi?id=1733165

Signed-off-by: Bishara AbuHattoum <bishara@daynix.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
bish22ah authored and mdroth committed Nov 4, 2019
1 parent 36609b4 commit a18025f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qga/commands-win32.c
Expand Up @@ -1387,12 +1387,12 @@ static IP_ADAPTER_ADDRESSES *guest_get_adapters_addresses(Error **errp)
static char *guest_wctomb_dup(WCHAR *wstr)
{
char *str;
size_t i;
size_t str_size;

i = wcslen(wstr) + 1;
str = g_malloc(i);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
wstr, -1, str, i, NULL, NULL);
str_size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
/* add 1 to str_size for NULL terminator */
str = g_malloc(str_size + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, str_size, NULL, NULL);
return str;
}

Expand Down

0 comments on commit a18025f

Please sign in to comment.