From nobody Mon Feb 9 17:22:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1621350952; cv=none; d=zohomail.com; s=zohoarc; b=GoTUtq8zHNb46FxP5rWZRprfKYu5CU+CpRN4yfKmMOZyp/XvcFf9Kn3nsaF/N50LMz6PxTAtUXCmF3qV9bRnqYcvlM7dBDYSBhf1HFISO7YmR+oWD1CZqOis0r5U8xWPpcYI4Ud7FZzP2WgtMKtBIPO74B9BvNZ93lAXrsPJ/9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621350952; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=krQ/Vl4bXkZzWtS/zBpEnAZemxKh/xQKDhWJE4MQKHEijmc7Lgc41J7gT1fwb8e/NmxHbVxbey47mABx6IDnQ7vbp6MR9Hd1LyHpL898SbLWlKDdL/TWXdIYdamLEWnAQ12JJE4IEsTISdbBkUwGpqc32T989LQuvrjPJLAMbco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621350952018170.90032335842284; Tue, 18 May 2021 08:15:52 -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-430-A3vmnPyGNC2wKcNuXM9sNw-1; Tue, 18 May 2021 11:05:46 -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 4117D802575; Tue, 18 May 2021 15:05:29 +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 1914B1037F22; Tue, 18 May 2021 15:05:29 +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 D60971801268; Tue, 18 May 2021 15:05:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14IF570E019337 for ; Tue, 18 May 2021 11:05:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3FABDE171; Tue, 18 May 2021 15:05:07 +0000 (UTC) Received: from work.redhat.com (ovpn-113-109.ams2.redhat.com [10.36.113.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BA7919D9F; Tue, 18 May 2021 15:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350349; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=S+eXgZLckY1Zg88iTgj4BOQwR2ep/Ql12zUbdR/wHGqmEJw6+7g4Upx2A19KxGY4tWxZw7 TfrEuE/IdU5vAjtWXUbs6QZnS8je2kwpfeWvTIx9ynywUL/F6+OoBpKU2jgyZXmGMRlfIt /99v44i/FpiDqUDGObwcNPL34telM/s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621350950; 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=XFMrp0uxXzBeDcySGU9u05P4bCZgw93UWD1+PGl3SVU=; b=C1Qhdsf8I8p/Vd9dX1QPS4SQ2BJEMah026nQobeCQJSosVDfG9dJvLiBAOhFxcsQopZp7f /HtbLZ8JeC6Pleji6wGlBobimsEgkAxLTJYH5RNf2k9lTR+yY3yGQREQLnF5HzRlRVTrRk ud6qiNAfB3Ae+9XYnIBBL0TVQM7huK8= X-MC-Unique: A3vmnPyGNC2wKcNuXM9sNw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] virDomainChrDefParseTargetXML: Use virXMLProp* Date: Tue, 18 May 2021 17:04:48 +0200 Message-Id: <20210518150451.79954-8-twiederh@redhat.com> In-Reply-To: <20210518150451.79954-1-twiederh@redhat.com> References: <20210518150451.79954-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `port`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake --- src/conf/domain_conf.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5514660cc..57a54f12ef 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10977,7 +10977,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, g_autofree char *targetModel =3D NULL; g_autofree char *addrStr =3D NULL; g_autofree char *portStr =3D NULL; - g_autofree char *stateStr =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D cur; @@ -11007,7 +11006,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, switch (def->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: addrStr =3D virXMLPropString(cur, "address"); - portStr =3D virXMLPropString(cur, "port"); =20 def->target.addr =3D g_new0(virSocketAddr, 1); =20 @@ -11028,19 +11026,8 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, return -1; } =20 - if (portStr =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does " - "not define a target port")); - return -1; - } - - if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); + if (virXMLPropUInt(cur, "port", 10, VIR_XML_PROP_REQUIRED, &po= rt) < 0) return -1; - } =20 virSocketAddrSetPort(def->target.addr, port); break; @@ -11050,18 +11037,12 @@ virDomainChrDefParseTargetXML(virDomainChrDef *de= f, def->target.name =3D virXMLPropString(cur, "name"); =20 if (def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= VIRTIO && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (stateStr =3D virXMLPropString(cur, "state"))) { - int tmp; + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { =20 - if ((tmp =3D virDomainChrDeviceStateTypeFromString(stateSt= r)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid channel state value '%s'"), - stateStr); + if (virXMLPropEnum(cur, "state", + virDomainChrDeviceStateTypeFromString, + VIR_XML_PROP_NONZERO, &def->state) < 0) return -1; - } - - def->state =3D tmp; } break; } --=20 2.26.3