From nobody Fri Apr 26 08:38:46 2024 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=1637601246; cv=none; d=zohomail.com; s=zohoarc; b=UV8GZBAoiweDA6HvRUFnIuzk6nPJY4007BjjQK0Aq4pIYjQv4b4XJgCJnvX2wYXwqHS69NlHnn0pz4ktNfSKpIUTSWRkbtPoJnL5o9fZn+FwL8U70lj1JAgenb+h4EP9Kh+31psdEUDwy6++U/lBBVR/rA9Z0jvwhnFyeIWj1DU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601246; 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=9ungaqIgHBziLXpSn+P5g06NOHy96VKnwl3veGX2Nns=; b=GH17rHViRzKO/7JnFOQlgpmnDQQ9blxRvdpul4S2VDiVocNzTe3wNjKGVwMx0VMpqthrUNf1c+KNOowtpaY5AJahuWpsOTdjZWEIkYlrkx/CAa9w/sWsncmIvwfB5qkq3kXGCwaP5q0ZXvDt9PIVNo/yGQA85gq2PiiPYshnWZU= 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 1637601246437645.5106505478686; Mon, 22 Nov 2021 09:14:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-bRyybsdMNaGZ0hv-D-xdog-1; Mon, 22 Nov 2021 12:13:09 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2284CC64B; Mon, 22 Nov 2021 17:13:00 +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 691545FCBB; Mon, 22 Nov 2021 17:13:00 +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 314841832E88; Mon, 22 Nov 2021 17:13:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCaST029269 for ; Mon, 22 Nov 2021 12:12:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3B6C360250; Mon, 22 Nov 2021 17:12:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C815FCD1 for ; Mon, 22 Nov 2021 17:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601245; 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=9ungaqIgHBziLXpSn+P5g06NOHy96VKnwl3veGX2Nns=; b=bLo546oUrxQCOKFU8hUehMmlyQIEo7mceGr0ezOWieYW4HNZN0w2HvP6zhOFbE06mqT9cO jtIllTL3jUSAPivsW8lBS7ui2oxDoRNAHINRS61jM47uzOdzDgCj3GEGErUAwptm2RSiMR tiAvjlzJYY9GmkrjPh+wAuRoIxNIxoY= X-MC-Unique: bRyybsdMNaGZ0hv-D-xdog-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/12] util: seclabel: Define autoptr cleanup func for virSecurityLabelDef and virSecurityDeviceLabelDef Date: Mon, 22 Nov 2021 18:12:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1637601247337100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virseclabel.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h index 18447051fc..77bf6da2c3 100644 --- a/src/util/virseclabel.h +++ b/src/util/virseclabel.h @@ -63,4 +63,7 @@ virSecurityDeviceLabelDefCopy(const virSecurityDeviceLabe= lDef *src) ATTRIBUTE_NONNULL(1); void virSecurityLabelDefFree(virSecurityLabelDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSecurityLabelDef, virSecurityLabelDefFree= ); + void virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSecurityDeviceLabelDef, virSecurityDevice= LabelDefFree); --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601192; cv=none; d=zohomail.com; s=zohoarc; b=GpMOOUr6nC8NgCuqtd2I0P5nGLwysjoLDZXGAHvrevz8i+4ETiS1rXxHqXjMFLSbtEE/xcu3ooR8dVUyBtygoVkqwcQVPuTJ6mTXzbKC5mGvy3v4Gg5fogj/QymyxU4N5ExBPz+1tUf3OQiaF6Cxb8GstDCp6oC2nWvMnA+2jlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601192; 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=KJ3IjAexe8O9pG7DfqW38ELZ8eLat1JsOmndbcNzrLU=; b=gu/augfsPY/dlEFNxB0M3aN4ryJU7/y8NWESFhkFpw6ZISwIaFi4vTJeHsAyamIXr5R7LjC4VKadsqch/DJWWlj3p4W94iwtU9qCC76Z9RAMGNKtUH/zDxRXYBI5wQGi5yBP2F4VfwK2noWA3yeElNE3SdZvHpvXgfxlsnQSckM= 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) 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 1637601192976688.7132294693299; Mon, 22 Nov 2021 09:13:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-oxg4QVwxO2665IRUiof8yg-1; Mon, 22 Nov 2021 12:13:10 -0500 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 10D0284F21F; Mon, 22 Nov 2021 17:13:04 +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 D77E11045D02; Mon, 22 Nov 2021 17:13:03 +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 A21E21832E81; Mon, 22 Nov 2021 17:13:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCbd0029284 for ; Mon, 22 Nov 2021 12:12:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id B1FC660FFD; Mon, 22 Nov 2021 17:12:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA4785FCD4 for ; Mon, 22 Nov 2021 17:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601191; 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=KJ3IjAexe8O9pG7DfqW38ELZ8eLat1JsOmndbcNzrLU=; b=iy+eBNUpNLNnfQ/rSsLKPEz5Xu3paPhUK6iIzUkPNa+FXvGw/VMes4Lmt9kz6RGRE62xUu 8Dh1lWQtqE5y5K4sfF7UGzS+cdf4nCW+vB93WZv6OiKEcDI0CntmhnmgUczLahJEQrESR1 hbcQQ+KfzLZ0YUHjHvuP6nR7TgZLr1I= X-MC-Unique: oxg4QVwxO2665IRUiof8yg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/12] virSecurityLabelDef: Declare 'type' as 'virDomainSeclabelType' Date: Mon, 22 Nov 2021 18:12:22 +0100 Message-Id: <749b2c767b510a45a168b5c5765ef918eebf3794.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637601194370100002 Content-Type: text/plain; charset="utf-8" Use the appropriate enum type instead of an int and fix the XML parser and one missing fully populated switch. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 14 +++++--------- src/security/security_selinux.c | 3 ++- src/util/virseclabel.h | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 552d43b845..ba38d510dd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7813,15 +7813,11 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, /* set default value */ seclabel->type =3D VIR_DOMAIN_SECLABEL_DYNAMIC; - p =3D virXMLPropString(ctxt->node, "type"); - if (p) { - seclabel->type =3D virDomainSeclabelTypeFromString(p); - if (seclabel->type <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid security type '%s'"), p); - goto error; - } - } + if (virXMLPropEnum(ctxt->node, "type", + virDomainSeclabelTypeFromString, + VIR_XML_PROP_NONZERO, + &seclabel->type) < 0) + goto error; if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC || seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_NONE) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 840a05844e..5682d2bb9d 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -899,7 +899,8 @@ virSecuritySELinuxGenLabel(virSecurityManager *mgr, mcs =3D g_strdup(sens); break; - + case VIR_DOMAIN_SECLABEL_DEFAULT: + case VIR_DOMAIN_SECLABEL_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected security label type '%s'"), diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h index 77bf6da2c3..eca4d09d24 100644 --- a/src/util/virseclabel.h +++ b/src/util/virseclabel.h @@ -37,7 +37,7 @@ struct _virSecurityLabelDef { char *label; /* security label string */ char *imagelabel; /* security image label string */ char *baselabel; /* base name of label string */ - int type; /* virDomainSeclabelType */ + virDomainSeclabelType type; /* virDomainSeclabelType */ bool relabel; /* true (default) for allowing relabels */ bool implicit; /* true if seclabel is auto-added */ }; --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601175; cv=none; d=zohomail.com; s=zohoarc; b=lIUMSBj1jonLmH+ciyZIHQvEvOfSlr7mgfxqbaOHsBvwfrAi1cCdgj/9E7dCLCXY+HE0kOweP2TOcQUJ1xw6vy9IQFIWy+ajX/N6BuzFIV5+Qlv9SfhY28SCA6/7a3IyzWi89HvcEf9rQQHLoR29iwYnc1+yD3dSjO5F1Vw4WkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601175; 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=k1W8k+UvxCqKRiEVOiIxteaYy8ckBMF4kcQNtqZZsK8=; b=iGWswuwLuZ1Szw3Kf8nm1JrWTg9Xwt9HYHzJu2yE/Eh65bsO/yQeyd1DlBMWSWrJ0s+YgN6Q9p1uWmuqqfsaN5WINoeojBsbJ+yr5HyaFK0hpPexCFZsdLaLNmJPZN5yIoDQEvNyXImmFimabT77RXnvGwnMqhIgeNY2QNmJQnE= 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) 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 1637601175655513.2545665660095; Mon, 22 Nov 2021 09:12:55 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-4bARlEtpP1WCl1DiJS7nUg-1; Mon, 22 Nov 2021 12:12:52 -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 7410D10823D8; Mon, 22 Nov 2021 17:12:42 +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 198BE5F93C; Mon, 22 Nov 2021 17:12:42 +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 09A661832E85; Mon, 22 Nov 2021 17:12:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCe3p029303 for ; Mon, 22 Nov 2021 12:12:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id ED92860C82; Mon, 22 Nov 2021 17:12:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42CE05FCB3 for ; Mon, 22 Nov 2021 17:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601174; 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=k1W8k+UvxCqKRiEVOiIxteaYy8ckBMF4kcQNtqZZsK8=; b=KjWeG5rsoRa5IYchIR3U+kOj03hXtf8guM/jxa22fN46Nm3Hsc1CGQTG9uif3L7d+ZDuJI 84jA98AAeBj+RM9d/YXNZJ+EiGDjB8XABHVuQqHjKtlaprP0x6u+XcmprHMPE4O/W0R8zb RDz2bvhlidHbVLqJ/KKvk8nG+4HJyj8= X-MC-Unique: 4bARlEtpP1WCl1DiJS7nUg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/12] virSecurityLabelDefParseXML: Directly assign strings into appropriate variables Date: Mon, 22 Nov 2021 18:12:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1637601177568100001 Content-Type: text/plain; charset="utf-8" 'seclabel->label', 'seclabel->imagelabel' and 'seclabel->baselabel' are populated by stealing the pointer from the 'p' temporary string. Remove the extra step. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba38d510dd..24de57005c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7874,36 +7874,32 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC || (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && seclabel->type !=3D VIR_DOMAIN_SECLABEL_NONE)) { - p =3D virXPathStringLimit("string(./label[1])", - VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - if (p =3D=3D NULL) { + seclabel->label =3D virXPathStringLimit("string(./label[1])", + VIR_SECURITY_LABEL_BUFLEN-1,= ctxt); + if (!seclabel->label) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security label is missing")); goto error; } - - seclabel->label =3D g_steal_pointer(&p); } /* Only parse imagelabel, if requested live XML with relabeling */ if (seclabel->relabel && (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && seclabel->type !=3D VIR_DOMAIN_SECLABEL_NONE)) { - p =3D virXPathStringLimit("string(./imagelabel[1])", - VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - if (p =3D=3D NULL) { + seclabel->imagelabel =3D virXPathStringLimit("string(./imagelabel[= 1])", + VIR_SECURITY_LABEL_BUFL= EN-1, ctxt); + if (!seclabel->imagelabel) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security imagelabel is missing")); goto error; } - seclabel->imagelabel =3D g_steal_pointer(&p); } /* Only parse baselabel for dynamic label type */ if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC) { - p =3D virXPathStringLimit("string(./baselabel[1])", - VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - seclabel->baselabel =3D g_steal_pointer(&p); + seclabel->baselabel =3D virXPathStringLimit("string(./baselabel[1]= )", + VIR_SECURITY_LABEL_BUFLE= N-1, ctxt); } return seclabel; --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601198; cv=none; d=zohomail.com; s=zohoarc; b=lsJbWJp7opplBC0bZQ7LxzcCzbZ78BmjybHvqctBtg6DrY8l/tJA46sFKebqw/ZaekukvgG1+bVDuq2C6LWvQ0ChQR3KDNddcqPfmaPLd7JgZQEm4PULavkdql9dN2sB15d58oZkpH0lZyptU6D6xJLOzkN5+kmJTigS3BiEHMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601198; 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=/k+x7ykL1j8wb4wGgcQ9gA1yyzQlIupZ/2NSZBsCmWE=; b=SVUdnqoZGmy5SDE8/cEzlCL/3x/o8hrxOmKJvrT+/zGVY6wkb6h87SIc0HIEhphh7+P2+sYiWVXUPeQ984E+XnhdxqWNzpIZXHgIxQUn0e0IzQNcBO+g7GjJrJsKVqZ0EJi6nfCLU81ilzn2Ks5sgAxue3/KM5BV+kGfZpKrgy4= 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 16376011981389.286659364012166; Mon, 22 Nov 2021 09:13:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-317-1SZ4AIKJMK6anLOi1spEYQ-1; Mon, 22 Nov 2021 12:13:12 -0500 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 C1C2F87504C; Mon, 22 Nov 2021 17:13:06 +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 91C61101E592; Mon, 22 Nov 2021 17:13:06 +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 586CE4EA38; Mon, 22 Nov 2021 17:13:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCeXP029309 for ; Mon, 22 Nov 2021 12:12:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id B118E5E9D0; Mon, 22 Nov 2021 17:12:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6480560240 for ; Mon, 22 Nov 2021 17:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601197; 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=/k+x7ykL1j8wb4wGgcQ9gA1yyzQlIupZ/2NSZBsCmWE=; b=QSbvcsFt+qCVhMUiboQNx2NeEhz7yFzYyhsnIZMsIGZUsP15PuOcUlLuDk498TTPrsFUu7 4V5GXKLs+9uzbND6qbt9NVYin3XsScWmulrhibr+wFExg3/3pbb+GTVMLUCD4dj6F9brZ9 JUff3aPpCwzIOZh25vFU8iHpO70JXuU= X-MC-Unique: 1SZ4AIKJMK6anLOi1spEYQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/12] virSecurityLabelDefParseXML: Don't reuse temporary string 'p' Date: Mon, 22 Nov 2021 18:12:24 +0100 Message-Id: <28315282c4721791b05b06f3db10d586f2e36101.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637601199796100001 Content-Type: text/plain; charset="utf-8" Use separate variables for 'model' and 'relabel' properties. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 20 ++++++++------------ src/util/virseclabel.h | 1 + 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 24de57005c..df0d033d0b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7800,15 +7800,15 @@ static virSecurityLabelDef * virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, unsigned int flags) { - char *p; + g_autofree char *model =3D NULL; + g_autofree char *relabel =3D NULL; virSecurityLabelDef *seclabel =3D NULL; - p =3D virXMLPropStringLimit(ctxt->node, "model", - VIR_SECURITY_MODEL_BUFLEN - 1); + model =3D virXMLPropStringLimit(ctxt->node, "model", + VIR_SECURITY_MODEL_BUFLEN - 1); - if (!(seclabel =3D virSecurityLabelDefNew(p))) + if (!(seclabel =3D virSecurityLabelDefNew(model))) goto error; - VIR_FREE(p); /* set default value */ seclabel->type =3D VIR_DOMAIN_SECLABEL_DYNAMIC; @@ -7823,16 +7823,13 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_NONE) seclabel->relabel =3D false; - VIR_FREE(p); - p =3D virXMLPropString(ctxt->node, "relabel"); - if (p) { - if (virStringParseYesNo(p, &seclabel->relabel) < 0) { + if ((relabel =3D virXMLPropString(ctxt->node, "relabel"))) { + if (virStringParseYesNo(relabel, &seclabel->relabel) < 0) { virReportError(VIR_ERR_XML_ERROR, - _("invalid security relabel value %s"), p); + _("invalid security relabel value '%s'"), relab= el); goto error; } } - VIR_FREE(p); if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC && !seclabel->relabel) { @@ -7905,7 +7902,6 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, return seclabel; error: - VIR_FREE(p); virSecurityLabelDefFree(seclabel); return NULL; } diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h index eca4d09d24..7e62f8a2e2 100644 --- a/src/util/virseclabel.h +++ b/src/util/virseclabel.h @@ -43,6 +43,7 @@ struct _virSecurityLabelDef { }; + /* Security configuration for device */ typedef struct _virSecurityDeviceLabelDef virSecurityDeviceLabelDef; struct _virSecurityDeviceLabelDef { --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601176; cv=none; d=zohomail.com; s=zohoarc; b=a4spy6bw6YcXofqj5GYjDCovDAT8ks1t6EnA5t8onOG+xDDDrOYR/72HFV9o9pXnOezlMLtKHtz6ej6mGHjqYUDdemZZIc5CZ8M69zOhJM06Hi/IGmaUWUcBdY8FjWDNglmqr6ynsOlty7RsXX4rRDjeehQ6siTWQcNUVl/O2hI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601176; 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=dkm5Odm0IvyV+VqLOMJBuwaoFGqMMxFsjg8dM3jdbWI=; b=Jg9nEDN45i/IbeRTLd+VTOl/g7gbtWCYsr5huo/ForT/X1Ua2EaH6jns7cW3SAakovObCOEEaKSHQIGCn1hA44B7o0wz6sW0dZ3GYm2l6zMiyRSGX3EM+3yx5bDWQzch4dn79nOWzD9cHNKlxRjLQy30HH4Jc8WdYVZhBvb3UR4= 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) 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 1637601176907856.176020442997; Mon, 22 Nov 2021 09:12:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-200-dExHiIwsNUGe0uKgTRmy0w-1; Mon, 22 Nov 2021 12:12:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0395A881276; Mon, 22 Nov 2021 17:12:43 +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 D493760CC3; Mon, 22 Nov 2021 17:12:42 +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 57D5C4A703; Mon, 22 Nov 2021 17:12:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCfCd029317 for ; Mon, 22 Nov 2021 12:12:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7647D60E1C; Mon, 22 Nov 2021 17:12:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB4D05C2E3 for ; Mon, 22 Nov 2021 17:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601175; 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=dkm5Odm0IvyV+VqLOMJBuwaoFGqMMxFsjg8dM3jdbWI=; b=anbWCwL8DP+mWur+nnamS0rzuFNnVxiZ7GpjtTTWsrkcddjEjj0CIVKncgsKNP+oIJSZaY QKfzd2hS0YeNaNzSSTSGkpETX1pE3hHQp6rG/nHKBNnSO8qE+Td7WxBb9XJ5PYJOmL+Hy/ X1JCxLhiIvCx+aY77Tozj53Bkjq3roo= X-MC-Unique: dExHiIwsNUGe0uKgTRmy0w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/12] virSecurityLabelDefParseXML: Use automatic freeing for 'seclabel' Date: Mon, 22 Nov 2021 18:12:25 +0100 Message-Id: <19735464925bb67d0e4edb57e6fe4455bf7007a4.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1637601177891100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index df0d033d0b..99bee98df8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7802,7 +7802,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, { g_autofree char *model =3D NULL; g_autofree char *relabel =3D NULL; - virSecurityLabelDef *seclabel =3D NULL; + g_autoptr(virSecurityLabelDef) seclabel =3D NULL; model =3D virXMLPropStringLimit(ctxt->node, "model", VIR_SECURITY_MODEL_BUFLEN - 1); @@ -7862,7 +7862,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, /* combination of relabel=3D'yes' and type=3D'static' * is checked a few lines above. */ } - return seclabel; + return g_steal_pointer(&seclabel); } /* Only parse label, if using static labels, or @@ -7899,10 +7899,9 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, VIR_SECURITY_LABEL_BUFLE= N-1, ctxt); } - return seclabel; + return g_steal_pointer(&seclabel); error: - virSecurityLabelDefFree(seclabel); return NULL; } --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601187; cv=none; d=zohomail.com; s=zohoarc; b=YKR0TiHmAB9dfw9oz2zl0nTyzS1FwnI+rGbzwGW3e5sqBMgdzInkuoM01uzDSSuSKiXbYN0dDxs69/VlX+haluoQhJ33tPwKl4gPWg4digDkWNqyw4qRnnZz8cNSUlDNuEl++oQQO1C5oYWoqQhEJseGKNO9Qkd5TLrKpiGnJhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601187; 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=HamAXS7QoHj8jcL3Wb3lZQ8dQ5qCKsmsD0T2r///DgA=; b=Xg8Nx4dT0kA4jX8hYzHI1mo98ipbrFKlciFZ5qWUqUPfNIJHqt7JmUsN1ey2YfFXo9Ofc3k6IrnNNhqfwVoLpUGmQmkCOtiSiyGHsvTmvUan495+8gT1RNyHN2FHrcrWgAy689isZVIvyKdDnOdfm0AnODhcXuQq7nIbVq6oPwM= 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 1637601187245226.92360693633827; Mon, 22 Nov 2021 09:13:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-gHtAu993NWKnp9OcaSvsTQ-1; Mon, 22 Nov 2021 12:12:55 -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 9C1BA19057D6; Mon, 22 Nov 2021 17:12:48 +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 7D870ADCD; Mon, 22 Nov 2021 17:12:48 +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 522781832E85; Mon, 22 Nov 2021 17:12:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCgAQ029324 for ; Mon, 22 Nov 2021 12:12:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9855B60FFE; Mon, 22 Nov 2021 17:12:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB19260CC3 for ; Mon, 22 Nov 2021 17:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601186; 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=HamAXS7QoHj8jcL3Wb3lZQ8dQ5qCKsmsD0T2r///DgA=; b=WJDbFi8PP6eDu2QJaMSzv/UbXW5oTI8C5cdt8pSziyXSUCXNWBmVs7xLdnOvTZAN3XvP3o 81aDmRJu9vX5I6UHerESV8bhKqrcgA3noa8TryQMnwD7Y3OwJlTrYfMx5iVPs/QuwdubXC UnZd7gAs8VqyAwR4aSDUG8MiKnP67lg= X-MC-Unique: gHtAu993NWKnp9OcaSvsTQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/12] virSecurityLabelDefParseXML: Remove pointless 'error' label Date: Mon, 22 Nov 2021 18:12:26 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1637601188476100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 99bee98df8..ee44bbbd4b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7808,7 +7808,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, VIR_SECURITY_MODEL_BUFLEN - 1); if (!(seclabel =3D virSecurityLabelDefNew(model))) - goto error; + return NULL; /* set default value */ seclabel->type =3D VIR_DOMAIN_SECLABEL_DYNAMIC; @@ -7817,7 +7817,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, virDomainSeclabelTypeFromString, VIR_XML_PROP_NONZERO, &seclabel->type) < 0) - goto error; + return NULL; if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC || seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_NONE) @@ -7827,7 +7827,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (virStringParseYesNo(relabel, &seclabel->relabel) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid security relabel value '%s'"), relab= el); - goto error; + return NULL; } } @@ -7835,13 +7835,13 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, !seclabel->relabel) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("dynamic label type must use resource relab= eling")); - goto error; + return NULL; } if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_NONE && seclabel->relabel) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("resource relabeling is not compatible with= 'none' label type")); - goto error; + return NULL; } /* For the model 'none' none of the following labels is going to be @@ -7857,7 +7857,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported type=3D'%s' to model 'none'"= ), virDomainSeclabelTypeToString(seclabel->typ= e)); - goto error; + return NULL; } /* combination of relabel=3D'yes' and type=3D'static' * is checked a few lines above. */ @@ -7876,7 +7876,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (!seclabel->label) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security label is missing")); - goto error; + return NULL; } } @@ -7889,7 +7889,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (!seclabel->imagelabel) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security imagelabel is missing")); - goto error; + return NULL; } } @@ -7900,9 +7900,6 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, } return g_steal_pointer(&seclabel); - - error: - return NULL; } static int --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601350; cv=none; d=zohomail.com; s=zohoarc; b=emjeYUR4ng8TBTBo88/VIPcjU9F9KqUoncYep/FvJgHSyzTiPY0Rr+7822uJQ937Zdvyio5jPj8kROyyaKTpJ6cXHN9SCk5sj5h6Q+rL9WMe6F6IwI43SAORENq490dmKMA23pIh4iCeRmfe6Q+GQMwmAQrTZp5KPw6d/84y1bQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601350; 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=gDcaZPVS0Wl8o/QLk0e4Et6IQv1oZWCSmQULz5wwtpw=; b=nqPfO0aMiBM/tvNsap2FtmbPpRlb/EQ2+g7e+J4Pou/DjhnxhY1Y8ZmnPnmbHylQdtpxPWBxgX7jYvXPGeeYKye38c4/b9VunH7vzoh2O8uXaMRw/sNftzU2VRxpFW6j8gwvoy56ObvVZOjgdg1Jlw9TwaxUBgNjY3qthobzHYw= 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) 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 1637601350851416.43629859392604; Mon, 22 Nov 2021 09:15:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534--0evpI0LNbuDXfpBJDjNyQ-1; Mon, 22 Nov 2021 12:13:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D4BA101F012; Mon, 22 Nov 2021 17:13:09 +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 1D26C60C5F; Mon, 22 Nov 2021 17:13:09 +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 E41121832E7F; Mon, 22 Nov 2021 17:13:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHChRP029339 for ; Mon, 22 Nov 2021 12:12:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id BE4CC60C5F; Mon, 22 Nov 2021 17:12:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B30860CCC for ; Mon, 22 Nov 2021 17:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601349; 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=gDcaZPVS0Wl8o/QLk0e4Et6IQv1oZWCSmQULz5wwtpw=; b=cAmaJgh69kAsnnzRXYWXQPgtlJwcakvuPvc4lPv9NGDgKOlNqjoG+Wx5oheh2MwpsFbqwX Nqb66x8yosLAIec0oU5sNVCxrz+SrCOEDrVIaMIy6ZQEy43GOU2Un1oe3qj5vJ0kFG1B2Y j84aYFXFlT4Y8Kbovb0/achVUsR5yg8= X-MC-Unique: -0evpI0LNbuDXfpBJDjNyQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/12] virNodeDeviceCapVPDParseCustomFields: Don't use 'virXPathStringLimit' Date: Mon, 22 Nov 2021 18:12:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1637601352955100001 Content-Type: text/plain; charset="utf-8" virXPathStringLimit doesn't give callers a way to differentiate between the queried XPath being empty and the length limit being exceeded. This means that callers are overwriting the error message. Move the length checks into the caller. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index ca534dfbed..0bac0fde8d 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -955,7 +955,8 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr= ctxt, virPCIVPDResource g_autofree char *keyword =3D NULL; ctxt->node =3D nodes[i]; - if (!(index =3D virXPathStringLimit("string(./@index[1])", 2, ctxt= ))) { + if (!(index =3D virXPathString("string(./@index[1])", ctxt)) || + strlen(index) > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _(" evaluation has failed")); continue; @@ -983,7 +984,8 @@ virNodeDeviceCapVPDParseCustomFields(xmlXPathContextPtr= ctxt, virPCIVPDResource VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node =3D nodes[i]; - if (!(index =3D virXPathStringLimit("string(./@index[1])", 2, = ctxt))) { + if (!(index =3D virXPathString("string(./@index[1])", ctxt)) || + strlen(index) > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _(" evaluation has failed")); continue; --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601184; cv=none; d=zohomail.com; s=zohoarc; b=RTexKc/w+GlT2OU4a9A18eEVRPXSVxd12S4ty4b5p0jzyLqaBVilU3eilmt+++KboIPuy+yC0Y2rHoi71BodXB4E42WgKhj+Jvjz5thm+A7aSxF42egVzpZb0svG5ZRkX9KL7HcHFHB7gboD4D/CkR7lfybx37xiLhygwE3NbsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601184; 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=7URl7U8TVc10n5SvqpGNXab7Ncl4Payy1EoSECpCovM=; b=n292/wcl/NgWWaHoP0KCxOdIsA5VWTprqXIEueXgL4Eyyy0fz/OdqrWHa4gOLSaNL60vnM6UbAp6RPKU9DOOKbdKb5ylxmZPDKiRKyIO4HVFDzHMQtopffowsERwgIsI4VbD5iQPEqzi8Z4ofOTdZjSifd1yHYdmhrv2XE0NomA= 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 163760118406987.75365369552355; Mon, 22 Nov 2021 09:13:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-d6xD1JcnMcKz59vhehM2oA-1; Mon, 22 Nov 2021 12:12:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C87C1906809; Mon, 22 Nov 2021 17:12:52 +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 2E44E60CD1; Mon, 22 Nov 2021 17:12:51 +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 E3FBD4E590; Mon, 22 Nov 2021 17:12:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCiOo029346 for ; Mon, 22 Nov 2021 12:12:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id F1CCC60C7F; Mon, 22 Nov 2021 17:12:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41EB760C5F for ; Mon, 22 Nov 2021 17:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601182; 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=7URl7U8TVc10n5SvqpGNXab7Ncl4Payy1EoSECpCovM=; b=Wl1ungxR5uvjov8dA5/B2Vo7ByI6ldyS3zHHAGDozzyCaa9cUDXLJKlY9Lv811dxpnt+PM GuV165AeoFMB3TeQIrGYiD1vusFJAKaikknNIQNx1NmVpxAwpSPJ/15NQCesOTdWhNvx+j al9IGDEQP4n/utePvibNdXxHVNnm0tU= X-MC-Unique: d6xD1JcnMcKz59vhehM2oA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/12] virSecurityLabelDefParseXML: Don't use 'virXPathStringLimit' Date: Mon, 22 Nov 2021 18:12:28 +0100 Message-Id: <723df54c84ac607358036171081aac0542ea410f.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1637601185669100001 Content-Type: text/plain; charset="utf-8" virXPathStringLimit doesn't give callers a way to differentiate between the queried XPath being empty and the length limit being exceeded. This means that callers are either overwriting the error message or ignoring it altogether. Move the length checks into the caller. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee44bbbd4b..bd9da0744d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7871,9 +7871,9 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC || (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && seclabel->type !=3D VIR_DOMAIN_SECLABEL_NONE)) { - seclabel->label =3D virXPathStringLimit("string(./label[1])", - VIR_SECURITY_LABEL_BUFLEN-1,= ctxt); - if (!seclabel->label) { + seclabel->label =3D virXPathString("string(./label[1])", ctxt); + if (!seclabel->label || + strlen(seclabel->label) >=3D VIR_SECURITY_LABEL_BUFLEN - 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security label is missing")); return NULL; @@ -7884,9 +7884,10 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, if (seclabel->relabel && (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && seclabel->type !=3D VIR_DOMAIN_SECLABEL_NONE)) { - seclabel->imagelabel =3D virXPathStringLimit("string(./imagelabel[= 1])", - VIR_SECURITY_LABEL_BUFL= EN-1, ctxt); - if (!seclabel->imagelabel) { + seclabel->imagelabel =3D virXPathString("string(./imagelabel[1])",= ctxt); + + if (!seclabel->imagelabel || + strlen(seclabel->imagelabel) >=3D VIR_SECURITY_LABEL_BUFLEN - = 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("security imagelabel is missing")); return NULL; @@ -7895,8 +7896,13 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, /* Only parse baselabel for dynamic label type */ if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC) { - seclabel->baselabel =3D virXPathStringLimit("string(./baselabel[1]= )", - VIR_SECURITY_LABEL_BUFLE= N-1, ctxt); + seclabel->baselabel =3D virXPathString("string(./baselabel[1])", c= txt); + + if (seclabel->baselabel && + strlen(seclabel->baselabel) >=3D VIR_SECURITY_LABEL_BUFLEN - 1= ) { + g_free(seclabel->baselabel); + seclabel->baselabel =3D NULL; + } } return g_steal_pointer(&seclabel); --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601252; cv=none; d=zohomail.com; s=zohoarc; b=N9ZIojfOrZmecI9x4cT0Z4Kg2l2kfYZ/lIEiNweAuEJFTq6B+HwzBGzjGWwE/SwjXo0Zzoo4zYfFOsPsbGNyqsWhdAN2P73wCBWp87fKhSYC+oHkSEGlD3ew48FXKHYlkaQypqVAKBIF23K2aplWQDQlkI3s/0QVl6a/RdpAQB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601252; 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=Y0Nsch0BnjSLvEcZZEG68MldZIHTsXjwLYRrKuufpF4=; b=LqEeWqBpCVwZu4FgrcOBIiGRvbEzWRGx+ztiTRrEg+sVa0RrH32Gd1IqneFLIisgJX61snpOZZb73YHXtgBvqG81oitT5dBJ2ka7Qd6oL5Gf72wesrnXlYildl0/CUdILZTN3GXIY10W2kdQOI39+YsQNnzrx7pN8UlaSjoNK8M= 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) 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 1637601252108248.1215830392265; Mon, 22 Nov 2021 09:14:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-a5uhXYz-MXyqvMH68dkJsg-1; Mon, 22 Nov 2021 12:13:17 -0500 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 31D82101F02F; Mon, 22 Nov 2021 17:13:12 +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 9DA771045E84; Mon, 22 Nov 2021 17:13:11 +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 7218C1832E88; Mon, 22 Nov 2021 17:13:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCkE0029361 for ; Mon, 22 Nov 2021 12:12:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5CA445FCD6; Mon, 22 Nov 2021 17:12:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71D4060C5F for ; Mon, 22 Nov 2021 17:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601251; 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=Y0Nsch0BnjSLvEcZZEG68MldZIHTsXjwLYRrKuufpF4=; b=SXGRGceBGZBXD03/2bVj28qs+IJ5JJW6T8SVFRHznC2GhwJC4jALfqjAIYB7owYbEY/qhT tvsffmiHcD2goLFCwVM9bBTMn6uI5rZHFuZ5GlAbMa4XCzYwo+eK1I26gjwYfXwAugVKl/ R2lsR4mO0LsmjYv+PkQJMlg/p6l2sFY= X-MC-Unique: a5uhXYz-MXyqvMH68dkJsg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/12] virSecurityDeviceLabelDefParseXML: Use automatic memory clearing for temp strings Date: Mon, 22 Nov 2021 18:12:29 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637601252323100001 Content-Type: text/plain; charset="utf-8" Apart from code simplification the refactor of 'model' fixes an unlikely memory leak of the string if a duplicate model is found. While the coversion of 'label' variable may seem unnecessary it will come in handy in the next patch. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bd9da0744d..e829511ac5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8016,7 +8016,10 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDef ***seclabels_rtn, size_t nseclabels =3D 0; int n; size_t i, j; - char *model, *relabel, *label, *labelskip; + g_autofree char *model =3D NULL; + g_autofree char *relabel =3D NULL; + g_autofree char *label =3D NULL; + g_autofree char *labelskip =3D NULL; g_autofree xmlNodePtr *list =3D NULL; if ((n =3D virXPathNodeSet("./seclabel", ctxt, &list)) < 0) @@ -8041,7 +8044,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDef ***seclabels_rtn, goto error; } } - seclabels[i]->model =3D model; + seclabels[i]->model =3D g_steal_pointer(&model); } relabel =3D virXMLPropString(list[i], "relabel"); @@ -8050,10 +8053,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDef ***seclabels_rtn, virReportError(VIR_ERR_XML_ERROR, _("invalid security relabel value %s"), relabel); - VIR_FREE(relabel); goto error; } - VIR_FREE(relabel); } else { seclabels[i]->relabel =3D true; } @@ -8063,14 +8064,13 @@ virSecurityDeviceLabelDefParseXML(virSecurityDevice= LabelDef ***seclabels_rtn, seclabels[i]->labelskip =3D false; if (labelskip && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->lab= elskip)); - VIR_FREE(labelskip); ctxt->node =3D list[i]; label =3D virXPathStringLimit("string(./label)", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - seclabels[i]->label =3D label; + seclabels[i]->label =3D g_steal_pointer(&label); - if (label && !seclabels[i]->relabel) { + if (seclabels[i]->label && !seclabels[i]->relabel) { virReportError(VIR_ERR_XML_ERROR, _("Cannot specify a label if relabelling is " "turned off. model=3D%s"), --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601309; cv=none; d=zohomail.com; s=zohoarc; b=felnrjk3H2yq5y89unxVOhKHRmvhIayaQI4cOU2ttXEjM28axzyelf0S3g3pR+iKsnXYGSUc7h39qRgABDoYxYhl2H95J0AGa92WDnwjWfEBJsSYHsgyiitOjwRgzcmq8bFHDsuupzaI5GzqS+mhumIBFH3rxIJKmF0y9pcr/cQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601309; 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=i4Jf19PV9pcAU7GGxor7u5VwDHlaIaDFtwHIYnuR3Ts=; b=Q7ffuUODlzCz2bW4AWm97gtrxrfJTzMvtdF7IVKflX224OcLE4Bs3tqPCeU8f8u1dnHgVTjQ0cOfoD1r5SIv++rj3Qpf6yK7/mgWGtBwpleEQ8NCAsFOXbuZ4Zc6JQ9OvV9HJVr9ClXOW8mVx7sKBUzyTaKI/xsM6S68XArZBjU= 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) 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 1637601309567423.3386640923642; Mon, 22 Nov 2021 09:15:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-XVyN7xcEPAGPWBrxpOXGfA-1; Mon, 22 Nov 2021 12:13:19 -0500 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 AF6231923782; Mon, 22 Nov 2021 17:13:14 +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 7E39D10023AB; Mon, 22 Nov 2021 17:13:14 +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 49B364EA38; Mon, 22 Nov 2021 17:13:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHClhW029366 for ; Mon, 22 Nov 2021 12:12:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E95960C5F; Mon, 22 Nov 2021 17:12:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2B6D60FFD for ; Mon, 22 Nov 2021 17:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601308; 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=i4Jf19PV9pcAU7GGxor7u5VwDHlaIaDFtwHIYnuR3Ts=; b=LA4lOzMES/ls0lb9VtvWv/2MibdFVXvxTPbSMeMOY4rKYsfDbwTZ72y+IbmTaWax/e1Idr UFIdTBlrFpNNOiF8QiJiIc8VvB/thS6bZv1sr4tVMvPEJpmG537mduTzZPQJ+RRhz0ZnuQ P3fCgj/F+QDqNFPmBUnfejKMcNqC4BI= X-MC-Unique: XVyN7xcEPAGPWBrxpOXGfA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/12] virSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit' Date: Mon, 22 Nov 2021 18:12:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637601311741100001 Content-Type: text/plain; charset="utf-8" virXPathStringLimit doesn't give callers a way to differentiate between the queried XPath being empty and the length limit being exceeded. This means that the callers is completely ignoring the error. Move the length check into the caller. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e829511ac5..d6eefed398 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8066,9 +8066,10 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDef ***seclabels_rtn, ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->lab= elskip)); ctxt->node =3D list[i]; - label =3D virXPathStringLimit("string(./label)", - VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - seclabels[i]->label =3D g_steal_pointer(&label); + label =3D virXPathString("string(./label)", ctxt); + + if (label && strlen(label) < VIR_SECURITY_LABEL_BUFLEN) + seclabels[i]->label =3D g_steal_pointer(&label); if (seclabels[i]->label && !seclabels[i]->relabel) { virReportError(VIR_ERR_XML_ERROR, --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601188; cv=none; d=zohomail.com; s=zohoarc; b=fPMAwcfBwYdGHN9wlmyKDR7x5jqB/RM1E0visWsrOKoT0kjaRQEqOq0kJpyNKXbTo29SWYPCabaar+japQh8ebGXKA3PRS3XV/D3EfthhTwJQ6Wz2f/+vEFHNq+BAquEfXcpZ+5P4criSPNnCm2nWxBRJLcqv/2iQc+O73VqMnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601188; 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=Efbx/KXzefH5wh95B047jS82+fISQXPpVqRf74BlwFE=; b=R/2ADLL/1kw4IKq2lKlkBV1CGnDBZWpXH3WfGssW5+s2xNzzqhih1qGyAgBMUoLEeKS2bZlbP/+AwS/lB3wGQwY3JSBIpRNA2QhcxvpK8WJawX/r02Z+47itifXHYbrPhiJWHRzMkbpLOxFi4J0CB0GTcDZvgpnE3gQThs8kQeM= 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 163760118833294.67081867346451; Mon, 22 Nov 2021 09:13:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-15-66fV_2dFOqWN-nEmuWRu-g-1; Mon, 22 Nov 2021 12:13:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B851A40CF; Mon, 22 Nov 2021 17:12:52 +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 2315B61082; Mon, 22 Nov 2021 17:12:52 +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 59A464EA38; Mon, 22 Nov 2021 17:12:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCmHP029377 for ; Mon, 22 Nov 2021 12:12:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9210A60CC3; Mon, 22 Nov 2021 17:12:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D890260C5F for ; Mon, 22 Nov 2021 17:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601187; 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=Efbx/KXzefH5wh95B047jS82+fISQXPpVqRf74BlwFE=; b=HjkRcmXeC5OfxJaYFewXjauOwDpsYc/5fgbirYhPdp0SRXmhKLRFiGhKVQxLHg4fEoEZrC jSAyscKwQdjDfMI2a65jm3EM0Qu3rtM2hZovFrDn3PK6U82BHZ3I5qjd3JV/p/M7/0/Gy9 bbL2+4wJI/rPlb8N00ATyvadg3Ur/ao= X-MC-Unique: 66fV_2dFOqWN-nEmuWRu-g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/12] virSecurityLabelDefParseXML: Don't use virXMLPropStringLimit Date: Mon, 22 Nov 2021 18:12:31 +0100 Message-Id: <777ebe6047f132e9686a2d37868e93f7efe91312.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1637601188924100003 Content-Type: text/plain; charset="utf-8" The function produces an error which is ignored in this code path. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d6eefed398..17ba810467 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7804,8 +7804,9 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, g_autofree char *relabel =3D NULL; g_autoptr(virSecurityLabelDef) seclabel =3D NULL; - model =3D virXMLPropStringLimit(ctxt->node, "model", - VIR_SECURITY_MODEL_BUFLEN - 1); + if ((model =3D virXMLPropString(ctxt->node, "model")) && + strlen(model) >=3D VIR_SECURITY_MODEL_BUFLEN - 1) + g_clear_pointer(&model, g_free); if (!(seclabel =3D virSecurityLabelDefNew(model))) return NULL; --=20 2.31.1 From nobody Fri Apr 26 08:38:46 2024 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=1637601207; cv=none; d=zohomail.com; s=zohoarc; b=WRsURhIMFrGJ9rWJoOrbLC/pQkoWiE4gZkcRSYv+/n0KdK/zkp75Aixnf4usUjQlG7dBo1hYCU8JBF3haQzowr9fxThiD68B/ghFgWcgKcXRbBEVQFkgJJpFW0cB55mIeAgwF+nJQXTQAMdQLZxMXqRD2CJBpMB7w5ii+6r2YZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637601207; 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=j946aY8XA/FyqVt34yGwyeJF+jQkXjOD2QXzG4kjO64=; b=kYdMQff410mWkYhVIDCqLK1W64z1ocexJ39CMlotVU+zgu6dIsOXY5aX7SKWE8vneRoyCUrK1LRN5Wwf4jfqeRsXhjHv393zEKhSmKmZEnvwEdBqyn67h260ETVQz7a1ei+hud7WI6xiBz5OR5kHtOWJ+62IfGkBE1xKKjwR3+Q= 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) 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 1637601207655124.26781843759215; Mon, 22 Nov 2021 09:13:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-h13XwIpnNqyQv4JXBcIiTA-1; Mon, 22 Nov 2021 12:13:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAC4CDF8A6; Mon, 22 Nov 2021 17:13:17 +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 B170460BD8; Mon, 22 Nov 2021 17:13:17 +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 7F72E4EA37; Mon, 22 Nov 2021 17:13:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AMHCnFP029392 for ; Mon, 22 Nov 2021 12:12:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id DB5FB60C7F; Mon, 22 Nov 2021 17:12:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FEA160C5F for ; Mon, 22 Nov 2021 17:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637601206; 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=j946aY8XA/FyqVt34yGwyeJF+jQkXjOD2QXzG4kjO64=; b=JR7cly+2vJG8gPxaCXn2vknNyFQoHqGrseRk1ThWDo0718OvxL5SJRDn9eRhN8dZcQ2dxS brbBJtUfymtWX4p/T9BVtNgws8vLOZpAc8DXKZgANs5wfkXhmCF35R9ytDKpRjqTU+aOAL qAMhX0KVGyIezqygka16tq5tKjUuhrU= X-MC-Unique: h13XwIpnNqyQv4JXBcIiTA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/12] util: xml: Remove virXMLPropStringLimit and virXPathStringLimit Date: Mon, 22 Nov 2021 18:12:32 +0100 Message-Id: <852a9d6f2428f3487be992bd010b23c4b3b7ba14.1637600984.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.11 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) X-ZM-MESSAGEID: 1637601208459100001 Content-Type: text/plain; charset="utf-8" The functions have very difficult semantics where callers are not able to tell whether the property is missing or failed the length check. Only the latter produces errors. Since usage of the functions was phased out, remove them completely to avoid further broken code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 2 -- src/util/virxml.c | 62 ---------------------------------------- src/util/virxml.h | 8 ------ 3 files changed, 72 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a7bc50a4d1..13b7266c97 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3625,7 +3625,6 @@ virXMLPropEnum; virXMLPropEnumDefault; virXMLPropInt; virXMLPropString; -virXMLPropStringLimit; virXMLPropTristateBool; virXMLPropTristateSwitch; virXMLPropUInt; @@ -3646,7 +3645,6 @@ virXPathNode; virXPathNodeSet; virXPathNumber; virXPathString; -virXPathStringLimit; virXPathUInt; virXPathULong; virXPathULongHex; diff --git a/src/util/virxml.c b/src/util/virxml.c index b736d59d9c..4b09374107 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -89,45 +89,6 @@ virXPathString(const char *xpath, } -static char * -virXMLStringLimitInternal(char *value, - size_t maxlen, - const char *name) -{ - if (value !=3D NULL && strlen(value) >=3D maxlen) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("'%s' value longer than '%zu' bytes"), - name, maxlen); - VIR_FREE(value); - return NULL; - } - - return value; -} - - -/** - * virXPathStringLimit: - * @xpath: the XPath string to evaluate - * @maxlen: maximum length permitted string - * @ctxt: an XPath context - * - * Wrapper for virXPathString, which validates the length of the returned - * string. - * - * Returns a new string which must be deallocated by the caller or NULL if - * the evaluation failed. - */ -char * -virXPathStringLimit(const char *xpath, - size_t maxlen, - xmlXPathContextPtr ctxt) -{ - char *tmp =3D virXPathString(xpath, ctxt); - - return virXMLStringLimitInternal(tmp, maxlen, xpath); -} - /** * virXPathNumber: * @xpath: the XPath string to evaluate @@ -492,29 +453,6 @@ virXMLPropString(xmlNodePtr node, } -/** - * virXMLPropStringLimit: - * @node: XML dom node pointer - * @name: Name of the property (attribute) to get - * @maxlen: maximum permitted length of the string - * - * Wrapper for virXMLPropString, which validates the length of the returned - * string. - * - * Returns a new string which must be deallocated by the caller or NULL if - * the evaluation failed. - */ -char * -virXMLPropStringLimit(xmlNodePtr node, - const char *name, - size_t maxlen) -{ - char *tmp =3D (char *)xmlGetProp(node, BAD_CAST name); - - return virXMLStringLimitInternal(tmp, maxlen, name); -} - - /** * virXMLNodeContentString: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index 06fb7aebd8..6f9f217f73 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -47,10 +47,6 @@ virXPathBoolean(const char *xpath, char * virXPathString(const char *xpath, xmlXPathContextPtr ctxt); -char * -virXPathStringLimit(const char *xpath, - size_t maxlen, - xmlXPathContextPtr ctxt); int virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, @@ -98,10 +94,6 @@ char * virXMLPropString(xmlNodePtr node, const char *name); char * -virXMLPropStringLimit(xmlNodePtr node, - const char *name, - size_t maxlen); -char * virXMLNodeContentString(xmlNodePtr node); int --=20 2.31.1