From 553f06d3ecdb93a9ddbe6c74d4411cc1d8a642a5 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 19 Jul 2015 23:30:28 +0200
Subject: degesch: fix literal IPv6 server addresses
---
degesch.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/degesch.c b/degesch.c
index 5876af0..d1d2a63 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4385,7 +4385,7 @@ irc_on_connector_connected (void *user_data, int socket)
static void
irc_split_host_port (char *s, char **host, char **port)
{
- char *colon = strchr (s, ':');
+ char *colon = strrchr (s, ':');
if (colon)
{
*colon = '\0';
@@ -4394,6 +4394,11 @@ irc_split_host_port (char *s, char **host, char **port)
else
*port = "6667";
+ // Unwrap IPv6 addresses in format_host_port_pair() format
+ size_t host_end = strlen (s) - 1;
+ if (*s == '[' && s[host_end] == ']')
+ s++[host_end] = '\0';
+
*host = s;
}
--
cgit v1.2.3-70-g09d2