From nobody Tue Nov 11 20:56:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566221320; cv=none; d=zoho.com; s=zohoarc; b=eI9SgemTYRZcFz4F+1FNJ3H0RYZ9ZoDQuKUDTZ34NNSeCJ0E+cylB2ajgwcZ1p6YTVB2ksOx6wJUwh2oEGSMshDkJYiudtxbsAME1EjnTNB5AREMcdI6C6ii8dloOOfS8Ye9KoPBzoZ6naE+I751K/INdTTsXeforJYcGPhoIVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566221320; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aoQ4htoVoyVhOjJeSxVJjBUxso2ojfg4A8CIjiLtp00=; b=ewfOCiFl1RnGoEX2OtC3yxNgRJk94r33ijxijTKbXHENc4WDJiVn4Fg0rLqwVuB1nhomlN0xeAgpclU7g+bAG0uFKhAbAfg4C9yhNNu2NDPtjZA7jMT3JE3zmfmd1yF34b4kt/PuPb5QRWKEicL5PX2cgH2iiKzlnAIn5WF2t9Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566221320314307.586198039504; Mon, 19 Aug 2019 06:28:40 -0700 (PDT) Received: from localhost ([::1]:51372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzhiB-0004WQ-6K for importer@patchew.org; Mon, 19 Aug 2019 09:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52184) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzhbS-0006xR-8v for qemu-devel@nongnu.org; Mon, 19 Aug 2019 09:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzhbP-0005bV-Tx for qemu-devel@nongnu.org; Mon, 19 Aug 2019 09:21:41 -0400 Received: from [141.226.163.173] (port=51533 helo=groan) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hzhbD-0005UO-PR for qemu-devel@nongnu.org; Mon, 19 Aug 2019 09:21:36 -0400 Received: by groan (Postfix, from userid 1000) id 88EC5208531AE; Mon, 19 Aug 2019 16:16:20 +0300 (IDT) From: Bishara AbuHattoum To: qemu-devel@nongnu.org, Michael Roth Date: Mon, 19 Aug 2019 16:16:20 +0300 Message-Id: <20190819131620.1302-2-bishara@daynix.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190819131620.1302-1-bishara@daynix.com> References: <20190819131620.1302-1-bishara@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 141.226.163.173 Subject: [Qemu-devel] [PATCH 1/1] qga-win: network-get-interfaces command name field bug fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Basil Salman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3D1733165 Signed-off-by: Bishara AbuHattoum --- 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_add= resses(Error **errp) static char *guest_wctomb_dup(WCHAR *wstr) { char *str; - size_t i; + size_t str_size; =20 - i =3D wcslen(wstr) + 1; - str =3D g_malloc(i); - WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, - wstr, -1, str, i, NULL, NULL); + str_size =3D WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, = NULL); + /* add 1 to str_size for NULL terminator */ + str =3D g_malloc(str_size + 1); + WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, str_size, NULL, NULL); return str; } =20 --=20 2.17.2