From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UotX7-0002kQ-EX for qemu-devel@nongnu.org; Tue, 18 Jun 2013 06:53:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UotX5-0002gn-PG for qemu-devel@nongnu.org; Tue, 18 Jun 2013 06:53:05 -0400 Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 18 Jun 2013 12:52:52 +0200 Message-Id: <1371552772-29179-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1371552772-29179-1-git-send-email-pbonzini@redhat.com> References: <1371552772-29179-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 2/2] nbd: strip braces from literal IPv6 address in URI List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?J=C3=A1n=20Tomko?= , mdroth@linux.vnet.ibm.com, qemu-stable@nongnu.org From: Ján Tomko Otherwise they would get passed to getaddrinfo and fail with: address resolution failed for [::1]:1234: Name or service not known (Broken by commit v1.4.0-736-gf17c90b) Signed-off-by: Ján Tomko Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- block/nbd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/nbd.c b/block/nbd.c index 30e3b78..9c480b8 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -118,13 +118,22 @@ static int nbd_parse_uri(const char *filename, QDict *options) } qdict_put(options, "path", qstring_from_str(qp->p[0].value)); } else { + QString *host; /* nbd[+tcp]://host[:port]/export */ if (!uri->server) { ret = -EINVAL; goto out; } - qdict_put(options, "host", qstring_from_str(uri->server)); + /* strip braces from literal IPv6 address */ + if (uri->server[0] == '[') { + host = qstring_from_substr(uri->server, 1, + strlen(uri->server) - 2); + } else { + host = qstring_from_str(uri->server); + } + + qdict_put(options, "host", host); if (uri->port) { char* port_str = g_strdup_printf("%d", uri->port); qdict_put(options, "port", qstring_from_str(port_str)); -- 1.8.1.4