From nobody Sun Feb 8 18:09:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1685705347; cv=none; d=zohomail.com; s=zohoarc; b=S7A4z5wWZGHnv1G1hQzNb7MJk4RpMgUFj+WPvq18RWrDUhxelGYoPxQdN/cXyDl9KG6A1tA1ece3JujzLd2vcMc231WmQjBpsE+11IV342jy3EBakeY/KjTtulC/VZdBmf3btwZGvkzUnZzFJMVSJLkepTcYN5n619WJn7lSqZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685705347; 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=9wXi4x0ftjEMBeR+8RYfeYpViucXtpVSWeJgoz3RgG8=; b=LZfazYz4VscLQVMjgS23B20SXSQcn7ynr7rDy3yiZQ63lPYFYSjd1nh3vb97hXA1o4A3fbwove1RFqh3V/wcedR3sTWZuZlXJbr8ZBqqJv2lIx7NLE4BPvQQwfk+hkLvvgoCqnuRFB2RXoGp2iSlB3a8iAate9oQMANLKb1VDXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1685705347066895.9900554379126; Fri, 2 Jun 2023 04:29:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-FWiJfRdFMOKaQTyhqn2fzw-1; Fri, 02 Jun 2023 07:28:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B5EE8032FE; Fri, 2 Jun 2023 11:28:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6D8B9E71; Fri, 2 Jun 2023 11:28:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 980921946595; Fri, 2 Jun 2023 11:28:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3F695194658C for ; Fri, 2 Jun 2023 11:28:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 10B859E9F; Fri, 2 Jun 2023 11:28:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 900F58162 for ; Fri, 2 Jun 2023 11:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685705346; 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=9wXi4x0ftjEMBeR+8RYfeYpViucXtpVSWeJgoz3RgG8=; b=L4BwEXKNZSm6tdP2MH3/eZ4vzHWSj5TekEhpxccu2ZzYqA+NOxbnu0uKDir9vxPUYKxmWf 4pFIA5I4WoX7iDzg4D2NDRaa0kZU8OLrS88XiptyLOiAa6TOeQ5rKRdSs5nfe0ECA/gaYW j92yl9W3h1bubUX7LHyYjhJ1TTgKYJU= X-MC-Unique: FWiJfRdFMOKaQTyhqn2fzw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/15] virNWFilterRuleParse: Parse 'priority' via 'virXMLPropInt' Date: Fri, 2 Jun 2023 13:28:21 +0200 Message-Id: <9a52c0a345ca72ba397c82a44ef0f6c6b779d8a4.1685705273.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685705347728100007 Content-Type: text/plain; charset="utf-8" Use modern parsing. Invalid numbers are now rejected. Semantis for numbers out of range is preserved. Signed-off-by: Peter Krempa --- src/conf/nwfilter_conf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 13c6096fcd..b7400b553a 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2373,18 +2373,15 @@ virNWFilterRuleDefFixup(virNWFilterRuleDef *rule) static virNWFilterRuleDef * virNWFilterRuleParse(xmlNodePtr node) { - g_autofree char *prio =3D NULL; g_autofree char *statematch =3D NULL; bool found; int found_i =3D 0; - int priority; xmlNodePtr cur; g_autoptr(virNWFilterRuleDef) ret =3D NULL; ret =3D g_new0(virNWFilterRuleDef, 1); - prio =3D virXMLPropString(node, "priority"); statematch =3D virXMLPropString(node, "statematch"); if (virXMLPropEnum(node, "action", virNWFilterRuleActionTypeFromString, @@ -2395,15 +2392,12 @@ virNWFilterRuleParse(xmlNodePtr node) VIR_XML_PROP_REQUIRED, &ret->tt) < 0) return NULL; - ret->priority =3D MAX_RULE_PRIORITY / 2; + if (virXMLPropInt(node, "priority", 10, VIR_XML_PROP_NONE, &ret->prior= ity, + MAX_RULE_PRIORITY / 2) < 0) + return NULL; - if (prio) { - if (virStrToLong_i(prio, NULL, 10, &priority) >=3D 0) { - if (priority <=3D MAX_RULE_PRIORITY && - priority >=3D MIN_RULE_PRIORITY) - ret->priority =3D priority; - } - } + if (ret->priority > MAX_RULE_PRIORITY || ret->priority < MIN_RULE_PRIO= RITY) + ret->priority =3D MAX_RULE_PRIORITY / 2; if (statematch && (STREQ(statematch, "0") || STRCASEEQ(statematch, "false"))) --=20 2.40.1