From nobody Mon Feb 9 03:47:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602074224; cv=none; d=zohomail.com; s=zohoarc; b=kOi3BFRA6G01F3E7hqpiMxcup0YoRV3RqnMa1PMOeZ7BLdqdTY+yA2ftwapdJQLw+Iep5gAjeeWEa/8wTfJFwe1pf1ebpPjAPx9tjCoMeX7p+qo/dXpP1OSFGJUxX8Ni5zjRr5Ps4hC3Y/ai620s1o0OTPg/0beYTt2GNf5y2t4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602074224; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d0a+vQrI47tdNnHMf9mfazedFKe954OpXEYJRhXgqxw=; b=LGCWZnLYQ+HyG0RZaIiCyUZKPWLyCKpNY4ArKkHeXRBjkKKYSH959OADIlHTY0XZmw8jgQ9n1i6CLGDE0osjtNcNhiO4om7Tin2GcKvnmbFsIQ+Kb8eycZMivY7hzca2HkBWE1q3f08st8RVJPUp7XQwPdNHN8JKOAFSU04OO8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602074224584865.4421477163894; Wed, 7 Oct 2020 05:37:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-wpFchEY2MLWNMqiWR4BapA-1; Wed, 07 Oct 2020 08:36:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3734D9CC12; Wed, 7 Oct 2020 12:36:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11EA21002C29; Wed, 7 Oct 2020 12:36:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CEAEA18408C2; Wed, 7 Oct 2020 12:36:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097CZpSv012528 for ; Wed, 7 Oct 2020 08:35:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97940702E7; Wed, 7 Oct 2020 12:35:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F8477664D for ; Wed, 7 Oct 2020 12:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602074223; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d0a+vQrI47tdNnHMf9mfazedFKe954OpXEYJRhXgqxw=; b=NbSPZX9b1Q3isZZgT2zI6rk89+vTUQFQxJos0mWqRw3+bZz7I1S7fjJzT0XGfioBl0e47t OjYZneAnkemZ/IPJiU8cUrLx7kv1oD9iRgHCQlW7/w9nVq1mBZuxPmP/uCqV6YYEED6R44 w7+TQCE5YNP/mP935hjnq7xjNdhqAkc= X-MC-Unique: wpFchEY2MLWNMqiWR4BapA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2 15/16] qemuAgentGetInterfaceOneAddress: check for errors early Date: Wed, 7 Oct 2020 14:35:36 +0200 Message-Id: <75018cef85786837a908f923003cb9fb8ee23681.1602074066.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For readability, and to ensure we do allocation when returning 0. Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 301707b136..60247e1616 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2073,11 +2073,9 @@ qemuAgentGetInterfaceOneAddress(virDomainIPAddressPt= r ip_addr, _("qemu agent didn't provide 'ip-address-type'" " field for interface '%s'"), name); return -1; - } else if (STREQ(type, "ipv4")) { - ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV4; - } else if (STREQ(type, "ipv6")) { - ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV6; - } else { + } + + if (STRNEQ(type, "ipv4") && STRNEQ(type, "ipv6")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown ip address type '%s'"), type); @@ -2091,7 +2089,6 @@ qemuAgentGetInterfaceOneAddress(virDomainIPAddressPtr= ip_addr, " field for interface '%s'"), name); return -1; } - ip_addr->addr =3D g_strdup(addr); =20 if (virJSONValueObjectGetNumberUint(ip_addr_obj, "prefix", &ip_addr->prefix) < 0) { @@ -2100,6 +2097,12 @@ qemuAgentGetInterfaceOneAddress(virDomainIPAddressPt= r ip_addr, return -1; } =20 + if (STREQ(type, "ipv4")) + ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV4; + else + ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV6; + + ip_addr->addr =3D g_strdup(addr); return 0; } =20 --=20 2.26.2