- /* 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));