summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r--lib/libfetch/fetch.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index ecf15b1..ad9932f 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -286,9 +286,18 @@ fetchParseURL(char *URL)
} else p = URL;
/* hostname */
- for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
- if (i < MAXHOSTNAMELEN)
- u->host[i++] = *p;
+#ifdef INET6
+ if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&
+ (*++q == '\0' || *q == '/' || *q == ':')) {
+ if ((i = q - p - 2) > MAXHOSTNAMELEN)
+ i = MAXHOSTNAMELEN;
+ strncpy(u->host, ++p, i);
+ p = q;
+ } else
+#endif
+ for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
+ if (i < MAXHOSTNAMELEN)
+ u->host[i++] = *p;
/* port */
if (*p == ':') {
OpenPOWER on IntegriCloud