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

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