From ac0c8510e21bcbe0ea018e8a45d9dfa9aafb18f5 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 7 Apr 2005 22:33:42 +0000 Subject: [PATCH] Tone down canonical-name resolution when using getaddrinfo(). Previously we were doing a forward+reverse lookup, which seems above and beyond the call of duty, especially given that getaddrinfo() can be persuaded to return a canonical name (this is what unix/uxnet.c does). Unfortunately, I'm unable to test this at all as Win98 doesn't have getaddrinfo(); hopefully I'll be able to find a mug with a modern version of Windows to check it's not completely broken. I think the effects of this are mostly cosmetic -- the canonical name is used for window titles (and some people have been annoyed at the new behaviour), other displays, and probably also for proxy exclusions. git-svn-id: svn://svn.tartarus.org/sgt/putty@5614 cda61777-01e9-0310-a592-d414129be87e --- windows/winnet.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/windows/winnet.c b/windows/winnet.c index f277e717..715c492f 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -368,6 +368,7 @@ SockAddr sk_namelookup(const char *host, char **canonicalname, struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = ret->family; + hints.ai_flags = AI_CANONNAME; if ((err = p_getaddrinfo(host, NULL, &hints, &ret->ais)) == 0) ret_family = ret->ais->ai_family; ret->ai = ret->ais; @@ -406,17 +407,10 @@ SockAddr sk_namelookup(const char *host, char **canonicalname, (char *) &((SOCKADDR_IN *) ret->ai-> ai_addr)->sin_addr, sizeof(a)); - /* Now let's find that canonicalname... */ - if (p_getnameinfo) { - if (p_getnameinfo - ((struct sockaddr *) ret->ai->ai_addr, - ret->family == - AF_INET ? sizeof(SOCKADDR_IN) : - sizeof(SOCKADDR_IN6), realhost, - sizeof(realhost), NULL, 0, 0) != 0) { - strncpy(realhost, host, sizeof(realhost)); - } - } + if (ret->ai->ai_canonname) + strncpy(realhost, ret->ai->ai_canonname, lenof(realhost)); + else + strncpy(realhost, host, lenof(realhost)); } /* We used the IPv4-only gethostbyname()... */ else -- 2.11.0