Blame SOURCES/libvirt-virDomainDiskAddISCSIPoolSourceHost-Sanitize-handling-of-string-list.patch

a41c76
From 39a1710d9a757391e6ecfdd5e1d5abd359e5a153 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <39a1710d9a757391e6ecfdd5e1d5abd359e5a153@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Wed, 19 Feb 2020 15:09:53 +0100
a41c76
Subject: [PATCH] virDomainDiskAddISCSIPoolSourceHost: Sanitize handling of
a41c76
 string list
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Use virStringSplitCount instead of virStringSplit so that we can drop
a41c76
the call to virStringListLength and use VIR_AUTOSTRINGLIST to declare
a41c76
it and allow removal of the cleanup section.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit c5b1c14379994369f5cb92bbb3da36d7d19150c2)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804603
a41c76
Message-Id: <a763fc4d91f223a097e8b709e46c066d348a9e31.1582120424.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/conf/domain_conf.c | 8 ++++----
a41c76
 1 file changed, 4 insertions(+), 4 deletions(-)
a41c76
a41c76
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
a41c76
index 68d9ce9c4e..6973d97e1d 100644
a41c76
--- a/src/conf/domain_conf.c
a41c76
+++ b/src/conf/domain_conf.c
a41c76
@@ -31174,7 +31174,8 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
a41c76
                                     virStoragePoolDefPtr pooldef)
a41c76
 {
a41c76
     int ret = -1;
a41c76
-    char **tokens = NULL;
a41c76
+    VIR_AUTOSTRINGLIST tokens = NULL;
a41c76
+    size_t ntokens;
a41c76
 
a41c76
     /* Only support one host */
a41c76
     if (pooldef->source.nhost != 1) {
a41c76
@@ -31195,10 +31196,10 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
a41c76
         pooldef->source.hosts[0].port : 3260;
a41c76
 
a41c76
     /* iscsi volume has name like "unit:0:0:1" */
a41c76
-    if (!(tokens = virStringSplit(def->src->srcpool->volume, ":", 0)))
a41c76
+    if (!(tokens = virStringSplitCount(def->src->srcpool->volume, ":", 0, &ntokens)))
a41c76
         goto cleanup;
a41c76
 
a41c76
-    if (virStringListLength((const char * const *)tokens) != 4) {
a41c76
+    if (ntokens != 4) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                        _("unexpected iscsi volume name '%s'"),
a41c76
                        def->src->srcpool->volume);
a41c76
@@ -31220,7 +31221,6 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
a41c76
     ret = 0;
a41c76
 
a41c76
  cleanup:
a41c76
-    virStringListFree(tokens);
a41c76
     return ret;
a41c76
 }
a41c76
 
a41c76
-- 
a41c76
2.25.0
a41c76