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

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