mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 21:12:47 -05:00
Use the new host_str* functions to improve IPv6 literal support.
I've gone through everywhere we handle host names / addresses (on command lines, in PuTTY config, in port forwarding, in X display names, in host key storage...) and tried to make them handle IPv6 literals sensibly, by using the host_str* functions I introduced in my previous commit. Generally it's now OK to use a bracketed IPv6 literal anywhere a hostname might have been valid; in a few cases where no ambiguity exists (e.g. no :port suffix is permitted anyway) unbracketed IPv6 literals are also acceptable. [originally from svn r10120]
This commit is contained in:
12
unix/uxnet.c
12
unix/uxnet.c
@ -221,7 +221,11 @@ SockAddr sk_namelookup(const char *host, char **canonicalname, int address_famil
|
||||
hints.ai_addr = NULL;
|
||||
hints.ai_canonname = NULL;
|
||||
hints.ai_next = NULL;
|
||||
err = getaddrinfo(host, NULL, &hints, &ret->ais);
|
||||
{
|
||||
char *trimmed_host = host_strduptrim(host); /* strip [] on literals */
|
||||
err = getaddrinfo(trimmed_host, NULL, &hints, &ret->ais);
|
||||
sfree(trimmed_host);
|
||||
}
|
||||
if (err != 0) {
|
||||
ret->error = gai_strerror(err);
|
||||
return ret;
|
||||
@ -868,7 +872,11 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i
|
||||
hints.ai_next = NULL;
|
||||
assert(port >= 0 && port <= 99999);
|
||||
sprintf(portstr, "%d", port);
|
||||
retcode = getaddrinfo(srcaddr, portstr, &hints, &ai);
|
||||
{
|
||||
char *trimmed_addr = host_strduptrim(srcaddr);
|
||||
retcode = getaddrinfo(trimmed_addr, portstr, &hints, &ai);
|
||||
sfree(trimmed_addr);
|
||||
}
|
||||
if (retcode == 0) {
|
||||
addr = (union sockaddr_union *)ai->ai_addr;
|
||||
addrlen = ai->ai_addrlen;
|
||||
|
Reference in New Issue
Block a user