mirror of
https://github.com/curl/curl.git
synced 2026-08-25 06:33:32 +03:00
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
This commit is contained in:
parent
6ce9845677
commit
715f1f53e0
5 changed files with 74 additions and 3 deletions
13
lib/hostip.c
13
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue