From nobody Sun Feb 8 22:59:44 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=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