qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name
@ 2019-08-19 13:16 Bishara AbuHattoum
  2019-08-19 13:16 ` [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix Bishara AbuHattoum
  2019-09-03  8:42 ` [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum
  0 siblings, 2 replies; 5+ messages in thread
From: Bishara AbuHattoum @ 2019-08-19 13:16 UTC (permalink / raw)
  To: qemu-devel, Michael Roth; +Cc: Yan Vugenfirer, Basil Salman

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

Uppon renaming a NIC to a Chinese name and invoking the network get
interfaces command, guest-network-get-interfaces, the returned name
field has the (\ufffd) value for each Chinese character the NIC name
had, this value is the indication that the code page does not have the
decoding information for the given character.

The suggested fix is to use the CP_UTF8 code page for decoding the NIC's
name instead of the CP_ACP code page.

Bishara AbuHattoum (1):
  qga-win: network-get-interfaces command name field bug fix

 qga/commands-win32.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.17.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix
  2019-08-19 13:16 [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum
@ 2019-08-19 13:16 ` Bishara AbuHattoum
  2019-09-03  8:42   ` Bishara AbuHattoum
  2019-09-12 23:35   ` Michael Roth
  2019-09-03  8:42 ` [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum
  1 sibling, 2 replies; 5+ messages in thread
From: Bishara AbuHattoum @ 2019-08-19 13:16 UTC (permalink / raw)
  To: qemu-devel, Michael Roth; +Cc: Yan Vugenfirer, Basil Salman

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>
---
 qga/commands-win32.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 6b67f16faf..64b1c754b0 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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;
 }
 
-- 
2.17.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name
  2019-08-19 13:16 [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum
  2019-08-19 13:16 ` [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix Bishara AbuHattoum
@ 2019-09-03  8:42 ` Bishara AbuHattoum
  1 sibling, 0 replies; 5+ messages in thread
From: Bishara AbuHattoum @ 2019-09-03  8:42 UTC (permalink / raw)
  To: QEMU Developers, Michael Roth; +Cc: Yan Vugenfirer, Basil Salman

PING

On Mon, Aug 19, 2019 at 4:22 PM Bishara AbuHattoum <bishara@daynix.com>
wrote:

> https://bugzilla.redhat.com/show_bug.cgi?id=1733165
>
> Uppon renaming a NIC to a Chinese name and invoking the network get
> interfaces command, guest-network-get-interfaces, the returned name
> field has the (\ufffd) value for each Chinese character the NIC name
> had, this value is the indication that the code page does not have the
> decoding information for the given character.
>
> The suggested fix is to use the CP_UTF8 code page for decoding the NIC's
> name instead of the CP_ACP code page.
>
> Bishara AbuHattoum (1):
>   qga-win: network-get-interfaces command name field bug fix
>
>  qga/commands-win32.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> --
> 2.17.2
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix
  2019-08-19 13:16 ` [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix Bishara AbuHattoum
@ 2019-09-03  8:42   ` Bishara AbuHattoum
  2019-09-12 23:35   ` Michael Roth
  1 sibling, 0 replies; 5+ messages in thread
From: Bishara AbuHattoum @ 2019-09-03  8:42 UTC (permalink / raw)
  To: QEMU Developers, Michael Roth; +Cc: Yan Vugenfirer, Basil Salman

PING

On Mon, Aug 19, 2019 at 4:28 PM Bishara AbuHattoum <bishara@daynix.com>
wrote:

> 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>
> ---
>  qga/commands-win32.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 6b67f16faf..64b1c754b0 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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;
>  }
>
> --
> 2.17.2
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix
  2019-08-19 13:16 ` [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix Bishara AbuHattoum
  2019-09-03  8:42   ` Bishara AbuHattoum
@ 2019-09-12 23:35   ` Michael Roth
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Roth @ 2019-09-12 23:35 UTC (permalink / raw)
  To: Bishara AbuHattoum, qemu-devel; +Cc: Yan Vugenfirer, Basil Salman

Quoting Bishara AbuHattoum (2019-08-19 08:16:20)
> 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>

Thanks, applied to qga tree:
  https://github.com/mdroth/qemu/commits/qga

> ---
>  qga/commands-win32.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 6b67f16faf..64b1c754b0 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -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;
>  }
> 
> -- 
> 2.17.2
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-13 22:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 13:16 [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum
2019-08-19 13:16 ` [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix Bishara AbuHattoum
2019-09-03  8:42   ` Bishara AbuHattoum
2019-09-12 23:35   ` Michael Roth
2019-09-03  8:42 ` [Qemu-devel] [PATCH 0/1] BZ#1733165: network-get-interfaces Chinese NIC name Bishara AbuHattoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).