From nobody Mon Feb 9 08:30:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642171265; cv=none; d=zohomail.com; s=zohoarc; b=Nc4XaER1WOCVAO06FuGUxht246qYozJsCURdVbCHeZM6OysDpBClUNWbr226qZ4Bh2lhiN1sl9T62WI4S1Qm5YA+t+uSLmg+t7CqV3RE2sCrVKECpo+WXlAHuXYVxNRy/TWAWfDWfnB+jX7tY5lBJLTlEzG+/MczpAaaDXQ9Uy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171265; 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=AIVGgclZZVVa0jdKLi70YDgQ7AdUr32hHS+yj/Vy4mQ=; b=Y7O30MY/uTfcXfSWMBJD/W+UJhvfESU8bm2+dp/jTLM5oCNHxnjIbyTIGMPRYgJ/w9/32ENDpqDD5HSIwiNgxfg5gtJZEvfdEV0IB3j+jUkMNrY/tpcs6ZWl2mf+tq7yKVVPi4JJsmibInQBysCPAbqsZk3/QLDrIBg35Cs//Gw= 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 1642171265626670.3541833109438; Fri, 14 Jan 2022 06:41:05 -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-587-Dtb13_mNNvWytsJaSqOs8A-1; Fri, 14 Jan 2022 09:40:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7160E1926DA8; Fri, 14 Jan 2022 14:40:27 +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 489F42BCC1; Fri, 14 Jan 2022 14:40:27 +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 168B418033AE; Fri, 14 Jan 2022 14:40:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeD3Y029260 for ; Fri, 14 Jan 2022 09:40:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5DD627B6EE; Fri, 14 Jan 2022 14:40:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7EB7B6EB for ; Fri, 14 Jan 2022 14:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171264; 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=AIVGgclZZVVa0jdKLi70YDgQ7AdUr32hHS+yj/Vy4mQ=; b=QlWWAHGjb74P1J0PBQnF0IJc6w9vGDwfMDEK09kc8DIhyy6T7eTdHaRbh/myTaKoym1lh4 jFKDxt1CeNKAoJPc0Qfcj2/Uqevbvw0Thv+xOQBW/Rj6IL65ehlR62McMYvh1SpmXJntTI 4wFdxvzcR5x4KlC1fHlrxWwiz3Yz85Q= X-MC-Unique: Dtb13_mNNvWytsJaSqOs8A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/11] libxl: Don't use a static buffer in xenParseXLVnuma() Date: Fri, 14 Jan 2022 15:39:50 +0100 Message-Id: <53c3b5a71ecb3c416c33e6e553913cca51469ed4.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.23 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: 1642171266407100003 Content-Type: text/plain; charset="utf-8" The xenParseXLVnuma() function is responsible for parsing 'vnuma' part of XL config and setting corresponding values in virDomainDef. While doing so it uses a static buffer which is set to data we are interested in and then parsing the buffer further (e.g. string to integer conversion, bitmap parsing, and so on). Well, the data we are interested in are already in a string (@data) which can be used directly rendering this intermediary buffer needless. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 43 ++++--------------------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 6e489f35ad..3a4e21ee0e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -394,7 +394,6 @@ xenParseXLVnuma(virConf *conf, virDomainDef *def) { int ret =3D -1; - char *tmp =3D NULL; size_t vcpus =3D 0; size_t nr_nodes =3D 0; size_t vnodeCnt =3D 0; @@ -446,19 +445,10 @@ xenParseXLVnuma(virConf *conf, data++; =20 if (*data) { - char vtoken[64]; - if (STRPREFIX(str, "pnode")) { unsigned int cellid; =20 - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu pnode '%s' t= oo long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if ((virStrToLong_ui(vtoken, NULL, 10, &cellid) < = 0) || + if ((virStrToLong_ui(data, NULL, 10, &cellid) < 0)= || (cellid >=3D nr_nodes)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma vnode %zu contains inv= alid pnode value '%s'"), @@ -467,27 +457,13 @@ xenParseXLVnuma(virConf *conf, } pnode =3D cellid; } else if (STRPREFIX(str, "size")) { - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu size '%s' to= o long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if (virStrToLong_ull(vtoken, NULL, 10, &kbsize) < = 0) + if (virStrToLong_ull(data, NULL, 10, &kbsize) < 0) goto cleanup; =20 virDomainNumaSetNodeMemorySize(numa, vnodeCnt, (kb= size * 1024)); =20 } else if (STRPREFIX(str, "vcpus")) { - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu vcpus '%s' t= oo long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if (virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_CP= UMASK_LEN) < 0) + if (virBitmapParse(data, &cpumask, VIR_DOMAIN_CPUM= ASK_LEN) < 0) goto cleanup; =20 virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumas= k); @@ -498,17 +474,7 @@ xenParseXLVnuma(virConf *conf, size_t i, ndistances; unsigned int value; =20 - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu vdistances '= %s' too long for destination"), - vnodeCnt, data); - goto cleanup; - } - - VIR_FREE(tmp); - tmp =3D g_strdup(vtoken); - - if (!(token =3D g_strsplit(tmp, ",", 0))) + if (!(token =3D g_strsplit(data, ",", 0))) goto cleanup; =20 ndistances =3D g_strv_length(token); @@ -571,7 +537,6 @@ xenParseXLVnuma(virConf *conf, cleanup: if (ret) VIR_FREE(cpu); - VIR_FREE(tmp); =20 return ret; } --=20 2.34.1