From nobody Mon Feb 9 14:14:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1573768809; cv=none; d=zoho.com; s=zohoarc; b=hLF3xHWe5YPcQqkpeNWRrhXyqOhLgPhfuP8sgItTyHSd8aFQ+CFntArJ1iTWaliJNDqsGLEEus9wrZgJlHh7Op6q8cywjoYE+0yFeSXQ/UVLrrRHMc6lxSa7TpZc5u+pFJ/3gvc77SrOS3mBmveEKGe4zYiSlIAJEj/kzRuitSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573768809; h=Content-Type:Content-Transfer-Encoding:Cc: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=spwMrzzI7eXCheS4PF7EGz7G0S6MWuNAW0RO7cNFeO0=; b=DHCgcQ6fit1O2FGsor6YjGu2/3Ki06m3L4HNqJcwyDWYni8sLgdYYpb/jUKcxtzZ/j4yAvwUtpas7xi6Lv39PDWwX2WeU9UOdn+17vxc4axcofESGI/lSGLUWDHxa37NWRoK6IjpptOlTRtz3ElOqzMrFKWU9EU2iDvmHptqLhI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573768809691542.1102442203309; Thu, 14 Nov 2019 14:00:09 -0800 (PST) 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-93-1nvtf7c0N72Q5L8K6OXLbg-1; Thu, 14 Nov 2019 17:00:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 766951802CE3; Thu, 14 Nov 2019 21:59: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 50B295E261; Thu, 14 Nov 2019 21:59: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 1424A180887A; Thu, 14 Nov 2019 21:59:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAELxLrM017633 for ; Thu, 14 Nov 2019 16:59:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8B6410246F4; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD0BD101F967; Thu, 14 Nov 2019 21:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573768808; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=spwMrzzI7eXCheS4PF7EGz7G0S6MWuNAW0RO7cNFeO0=; b=RjxUH1szaPjFCbfxAlC4U30lXkgRrCN39aVS3gS9l1AerNHOYan/vylX04/GKLGXPb8U4I Le8c8wB2sRXROcr09E22Do3Z6AKhXbGggWV3/N8a9e87h0ArBHGMErMC9NHNVz/fu3WED/ 4dsRoZvo2PieDAf67+VpSv2zI57Z0ek= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 15:59:15 -0600 Message-Id: <20191114215917.25513-3-jjongsma@redhat.com> In-Reply-To: <20191114215917.25513-1-jjongsma@redhat.com> References: <20191114215917.25513-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: crobinso@redhat.com Subject: [libvirt] [PATCH v3 2/4] conf: report errors when parsing video resolution 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.79 on 10.5.11.14 X-MC-Unique: 1nvtf7c0N72Q5L8K6OXLbg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The current code doesn't properly handle errors when parsing a video device's resolution. We were returning a NULL structure for the case where 'x' or 'y' were missing. But for the other error cases, we were logging an error (virReportError()), but still returning an under-specified structure. That under-specified structure was used by the calling function rather than properly reporting an error. This patch changes the parse function to return NULL on any parsing error and changes the calling function to report an error when NULL is returned. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c86729258..b0599c7318 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15309,24 +15309,26 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr no= de) x =3D virXMLPropString(node, "x"); y =3D virXMLPropString(node, "y"); =20 - if (!x || !y) + if (!x || !y) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing values for resolution")); return NULL; + } =20 def =3D g_new0(virDomainVideoResolutionDef, 1); =20 if (virStrToLong_uip(x, NULL, 10, &def->x) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video x-resolution '%s'"), x); - goto cleanup; + return NULL; } =20 if (virStrToLong_uip(y, NULL, 10, &def->y) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video y-resolution '%s'"), y); - goto cleanup; + return NULL; } =20 - cleanup: return g_steal_pointer(&def); } =20 @@ -15415,8 +15417,10 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, virXMLNodeNameEqual(child, "acceleration")) def->accel =3D virDomainVideoAccelDefParseXML(= child); if (def->res =3D=3D NULL && - virXMLNodeNameEqual(child, "resolution")) - def->res =3D virDomainVideoResolutionDefParseX= ML(child); + virXMLNodeNameEqual(child, "resolution")) { + if ((def->res =3D virDomainVideoResolutionDefP= arseXML(child)) =3D=3D NULL) + goto error; + } } child =3D child->next; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list