From nobody Thu Mar 28 09:02:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568105160; cv=none; d=zoho.com; s=zohoarc; b=HkKM/nS1ZaZgAXnXtrw4nrAgXr5mY0ZLJJH03ZvENjBw50DdPWP0svVTZpvEhvaOudyNVnM9VQJG/HgkzouNVe+Izg1iWHr+lDc35L38BegWxFMUcSjPQZO81Jcv4L8Nf5smT41TI5p8RQjZI452U2YOg/Mr4L29V5FBoqo37v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568105160; 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:ARC-Authentication-Results; bh=bX/Mb6HQ6sUTZJiiqKosi3vhs03aBY9egeAhWnGbZTM=; b=ome7HhoAjNeYyTDloGylHMysEty1Z9zZecpAGBWSpsclGZpNlrsNjyO36qoYTH5Lt8jEUAYO4ohUvHJ7Ka+5rtQA+ldhvqyVjTEvA5jT2opkLzqS5/0aQzAwckkdFjx4Nxzgs46Xjj3TAqs9EARThrdENw64rFwFM0x97D72aVA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568105160063964.3113484432187; Tue, 10 Sep 2019 01:46:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DCB5C099443; Tue, 10 Sep 2019 08:45:57 +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 6BBC45C224; Tue, 10 Sep 2019 08:45:57 +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 175BF180B536; Tue, 10 Sep 2019 08:45:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8A8jdMD024367 for ; Tue, 10 Sep 2019 04:45:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37B3360624; Tue, 10 Sep 2019 08:45:39 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B40560852 for ; Tue, 10 Sep 2019 08:45:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CF0D0100100; Tue, 10 Sep 2019 10:45:25 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 10 Sep 2019 10:45:23 +0200 Message-Id: <551806a0a6c5c1d91d9d5e9e900cb1d53f1bae5a.1568105090.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] conf: Add cleanup label to virDomainDefParse 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 10 Sep 2019 08:45:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7f49c8253f..17ddebb575 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21517,16 +21517,18 @@ virDomainDefParse(const char *xmlStr, void *parseOpaque, unsigned int flags) { - xmlDocPtr xml; + xmlDocPtr xml =3D NULL; virDomainDefPtr def =3D NULL; int keepBlanksDefault =3D xmlKeepBlanksDefault(0); =20 - if ((xml =3D virXMLParse(filename, xmlStr, _("(domain_definition)"))))= { - def =3D virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, - xmlopt, parseOpaque, flags); - xmlFreeDoc(xml); - } + if (!(xml =3D virXMLParse(filename, xmlStr, _("(domain_definition)")))) + goto cleanup; =20 + def =3D virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, + xmlopt, parseOpaque, flags); + + cleanup: + xmlFreeDoc(xml); xmlKeepBlanksDefault(keepBlanksDefault); return def; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 09:02:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568105143; cv=none; d=zoho.com; s=zohoarc; b=ejKi8Cpmu6Oq4+nt1R04VuapznSW6JIJqiSJBjxpHF0aRuygaeUL+AwcldfHIBLCSMJ629SF4xpijJqssinZFnr95L7yo3YGLKbZk8Cie6qLK4vx1y21VaqeM6oOo7rAiWrBpnOuKrsAoK6bN1Wi8MTA44juhokEtuu7Rtu6rhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568105143; 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:ARC-Authentication-Results; bh=NkzspsIkwpue3Ea2y/HXiGWM+CCs43DiVoKx+K0zhUk=; b=O2LRMVJUxcLNV+PqaWT9X5e32insemjx4JF19M8ltTRE85Mm9IbZcatrlJDb1rv85OGmRQtq/3QGPLZeAxIziJ32vqx7lN4NCxrCd81hzIIZOV2d1c5R8dMBlb2Pbgl3LtOF2/n/CDqTpBtprV7WSzayKGsltCrdymBgRhxyZFE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568105143074817.9605311935971; Tue, 10 Sep 2019 01:45:43 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4E44010E7A2E; Tue, 10 Sep 2019 08:45:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0484D1001959; Tue, 10 Sep 2019 08:45:41 +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 85B7924F30; Tue, 10 Sep 2019 08:45:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8A8jdSR024368 for ; Tue, 10 Sep 2019 04:45:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39A4D60852; Tue, 10 Sep 2019 08:45:39 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C5206061E for ; Tue, 10 Sep 2019 08:45:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D2880105239; Tue, 10 Sep 2019 10:45:25 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 10 Sep 2019 10:45:24 +0200 Message-Id: <63cb572a11cea36b2148a4627136952ea98c73f0.1568105090.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] conf: Avoid checking root element name in virDomainDefParseNode 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Tue, 10 Sep 2019 08:45:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The only caller for which this check makes sense is virDomainDefParse. Thus the check should be moved there. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 17ddebb575..b3b8c543d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21520,12 +21520,21 @@ virDomainDefParse(const char *xmlStr, xmlDocPtr xml =3D NULL; virDomainDefPtr def =3D NULL; int keepBlanksDefault =3D xmlKeepBlanksDefault(0); + xmlNodePtr root; =20 if (!(xml =3D virXMLParse(filename, xmlStr, _("(domain_definition)")))) goto cleanup; =20 - def =3D virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, - xmlopt, parseOpaque, flags); + root =3D xmlDocGetRootElement(xml); + if (!virXMLNodeNameEqual(root, "domain")) { + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting "), + root->name); + goto cleanup; + } + + def =3D virDomainDefParseNode(xml, root, caps, xmlopt, parseOpaque, fl= ags); =20 cleanup: xmlFreeDoc(xml); @@ -21566,14 +21575,6 @@ virDomainDefParseNode(xmlDocPtr xml, virDomainDefPtr def =3D NULL; virDomainDefPtr ret =3D NULL; =20 - if (!virXMLNodeNameEqual(root, "domain")) { - virReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting "), - root->name); - goto cleanup; - } - ctxt =3D xmlXPathNewContext(xml); if (ctxt =3D=3D NULL) { virReportOOMError(); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list