summaryrefslogtreecommitdiff
path: root/lib/hostip.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-11-17 11:21:12 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-11-17 15:26:08 +0100
commit715f1f53e0cf8ce5dc6f31f4ac6677f36e1927dc (patch)
tree6b84ef8aa137acfe1590a65d3a45c09f8d65c108 /lib/hostip.c
parent6ce98456774792ee5fd798f18660d98facede739 (diff)
downloadcurl-715f1f53e0cf8ce5dc6f31f4ac6677f36e1927dc.tar.gz
resolve: allow IP address within [] brackets
... so that IPv6 addresses can be passed like they can for connect-to and how they're used in URLs. Added test 1324 to verify Reported-by: Alex Malinovich Fixes #2087 Closes #2091
Diffstat (limited to 'lib/hostip.c')
-rw-r--r--lib/hostip.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index abe98028c..7f010a037 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -778,7 +778,6 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
{
struct curl_slist *hostp;
char hostname[256];
- char address[256];
int port;
for(hostp = data->change.resolve; hostp; hostp = hostp->next) {
@@ -820,6 +819,8 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
Curl_addrinfo *addr;
char *entry_id;
size_t entry_len;
+ char buffer[256];
+ char *address = &buffer[0];
if(3 != sscanf(hostp->data, "%255[^:]:%d:%255s", hostname, &port,
address)) {
@@ -828,6 +829,16 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
continue;
}
+ /* allow IP(v6) address within [brackets] */
+ if(address[0] == '[') {
+ size_t alen = strlen(address);
+ if(address[alen-1] != ']')
+ /* it needs to also end with ] to be valid */
+ continue;
+ address[alen-1] = 0; /* zero terminate there */
+ address++; /* pass the open bracket */
+ }
+
addr = Curl_str2addr(address, port);
if(!addr) {
infof(data, "Address in '%s' found illegal!\n", hostp->data);