From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHrNN-0001UA-2U for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHrNL-0007am-EO for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:40 -0400 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:37005) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHrNH-0007Rw-BM for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:35 -0400 Received: by mail-oi1-x244.google.com with SMTP id w66-v6so9427619oiw.4 for ; Wed, 31 Oct 2018 07:21:18 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Wed, 31 Oct 2018 09:19:08 -0500 Message-Id: <20181031141925.30026-8-mdroth@linux.vnet.ibm.com> In-Reply-To: <20181031141925.30026-1-mdroth@linux.vnet.ibm.com> References: <20181031141925.30026-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL v3 07/24] qga-win: prevent crash when executing fsinfo command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Sameeh Jubran , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= From: Sameeh Jubran The fsinfo command is currently implemented for Windows only and it's disk parameter can be enabled by adding the define "CONFIG_QGA_NTDDSCSI" to the qga code. When enabled and executed the qemu-ga crashed with the following message: ------------------------------------------------ File qapi/qapi-visit-core.c, Line 49 Expression: !(v->type & VISITOR_OUTPUT) || *obj) ------------------------------------------------ After some digging, turns out that the GuestPCIAddress is null and the qapi visitor doesn't like that, so we can always allocate it instead and initiate all it's members to -1. Signed-off-by: Sameeh Jubran Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth Signed-off-by: Tomáš Golembiovský Signed-off-by: Michael Roth --- qga/commands-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 347577f2a4..f0e6f6128b 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -499,6 +499,11 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) char *buffer = NULL; GuestPCIAddress *pci = NULL; char *name = g_strdup(&guid[4]); + pci = g_malloc0(sizeof(*pci)); + pci->domain = -1; + pci->slot = -1; + pci->function = -1; + pci->bus = -1; if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device name"); @@ -570,7 +575,6 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) func = addr & 0x0000FFFF; dev = (addr >> 16) & 0x0000FFFF; - pci = g_malloc0(sizeof(*pci)); pci->domain = dev; pci->slot = slot; pci->function = func; -- 2.17.1