diff options
-rw-r--r-- | lib/url.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -105,6 +105,7 @@ int curl_win32_idn_to_ascii(const char *in, char **out); #include "rawstr.h" #include "warnless.h" #include "non-ascii.h" +#include "inet_pton.h" /* And now for the protocols */ #include "ftp.h" @@ -4495,8 +4496,19 @@ static CURLcode parse_remote_port(struct SessionHandle *data, portptr = NULL; /* no port number available */ } } - else + else { +#ifdef ENABLE_IPV6 + struct in6_addr in6; + if(Curl_inet_pton(AF_INET6, conn->host.name, &in6) > 0) { + /* This is a numerical IPv6 address, meaning this is a wrongly formatted + URL */ + failf(data, "IPv6 numerical address used in URL without brackets"); + return CURLE_URL_MALFORMAT; + } +#endif + portptr = strrchr(conn->host.name, ':'); + } if(data->set.use_port && data->state.allow_port) { /* if set, we use this and ignore the port possibly given in the URL */ |