From nobody Mon Apr 29 08:13:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1510068438555465.06980340964935; Tue, 7 Nov 2017 07:27:18 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E30D420272; Tue, 7 Nov 2017 15:27:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A24056A023; Tue, 7 Nov 2017 15:27:15 +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 754744BB79; Tue, 7 Nov 2017 15:27:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA7FRDO9027748 for ; Tue, 7 Nov 2017 10:27:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 554685D756; Tue, 7 Nov 2017 15:27:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA3B05EDE0; Tue, 7 Nov 2017 15:27:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E30D420272 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 7 Nov 2017 16:26:51 +0100 Message-Id: <8b833ac17a6437f962e2ec288ab6f587fd10b115.1510068411.git.pkrempa@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH] util: storage: Fix parsing of IPv6 portal address for iSCSI 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 07 Nov 2017 15:27:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split on the last colon and avoid parsing port if the split remainder contains the closing square bracket, so that IPv6 addresses are interpreted correctly. --- src/util/virstoragefile.c | 3 ++- tests/virstoragetest.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3a2d2aa05..e7fcb1238 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3008,7 +3008,8 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourc= ePtr src, if (VIR_STRDUP(src->hosts->name, portal) < 0) goto cleanup; - if ((port =3D strchr(src->hosts->name, ':'))) { + if ((port =3D strrchr(src->hosts->name, ':')) && + !strchr(port, ']')) { if (virStringParsePort(port + 1, &src->hosts->port) < 0) goto cleanup; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index cfcd8a79c..52a685d91 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1578,6 +1578,26 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"[2001::0]:1234\"," + "\"target\":\"iqn.2016-12.com.virtt= est:emulated-iscsi-noauth.target\"," + "\"lun\":6" + "}" + "}", + "\n" + " \n" + "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"[2001::0]\"," + "\"target\":\"iqn.2016-12.com.virtt= est:emulated-iscsi-noauth.target\"," + "\"lun\":6" + "}" + "}", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\"," "\"vdi\":\"test\"," "\"server\":{ \"type\":\"inet\"," --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list