From nobody Mon Feb 9 00:56:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580910217369231.10973629172622; Wed, 5 Feb 2020 05:43:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-bzOiYYl8PhCmooi3gTzr6w-1; Wed, 05 Feb 2020 08:43:34 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24ED28010FC; Wed, 5 Feb 2020 13:43:28 +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 019FB5C541; Wed, 5 Feb 2020 13:43:28 +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 B15B718089D0; Wed, 5 Feb 2020 13:43:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df5H1008388 for ; Wed, 5 Feb 2020 08:41:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 924E11001B09; Wed, 5 Feb 2020 13:41:05 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A8281001B05 for ; Wed, 5 Feb 2020 13:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910216; 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=W5at56XpC0j4vb0xQ5LKIdXqyPULS/kqwKqSpJQOMAg=; b=EsCCwAuzt7O03lZfbdUmBn0YX/uOQ39TD8ojWDgppQOLSLzKZnRkTKFJ/NRwm6AzhC7CdN TVsFfd21uNEOjv0y9zxNVkSsBnMFVZP4BgmvaWnsdMfgObuqL1cRD9hx1PcDv7vBXazBPP ot8BnQyOkt9IVjKvrUtVQ00JRM9mVV4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/9] virDomainDiskAddISCSIPoolSourceHost: Sanitize handling of string list Date: Wed, 5 Feb 2020 14:40:52 +0100 Message-Id: <885ac66befa22aa8a5ec1d95c90e138a908a4411.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 X-MC-Unique: bzOiYYl8PhCmooi3gTzr6w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use virStringSplitCount instead of virStringSplit so that we can drop the call to virStringListLength and use VIR_AUTOSTRINGLIST to declare it and allow removal of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c95bd34fb5..6124c7520c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31327,7 +31327,8 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, virStoragePoolDefPtr pooldef) { int ret =3D -1; - char **tokens =3D NULL; + VIR_AUTOSTRINGLIST tokens =3D NULL; + size_t ntokens; /* Only support one host */ if (pooldef->source.nhost !=3D 1) { @@ -31348,10 +31349,10 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDisk= DefPtr def, pooldef->source.hosts[0].port : 3260; /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) + if (!(tokens =3D virStringSplitCount(def->src->srcpool->volume, ":", 0= , &ntokens))) goto cleanup; - if (virStringListLength((const char * const *)tokens) !=3D 4) { + if (ntokens !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected iscsi volume name '%s'"), def->src->srcpool->volume); @@ -31373,7 +31374,6 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, ret =3D 0; cleanup: - virStringListFree(tokens); return ret; } --=20 2.24.1