From 29c8c6e1cdb4b11ce4b352363f49d27cde10d8ad Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 27 Sep 2000 23:45:17 +0000 Subject: [PATCH] net_gethostbyaddr() fixed. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@685 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/network.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/core/network.c b/src/core/network.c index 7c800ac1..4a60a963 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -362,7 +362,6 @@ int net_gethostbyaddr(IPADDR *ip, char **name) { #ifdef HAVE_IPV6 struct addrinfo req, *ai; - char hbuf[NI_MAXHOST]; int host_error; #else struct hostent *hp; @@ -378,19 +377,15 @@ int net_gethostbyaddr(IPADDR *ip, char **name) #ifdef HAVE_IPV6 memset(&req, 0, sizeof(struct addrinfo)); req.ai_socktype = SOCK_STREAM; + req.ai_flags = AI_CANONNAME; /* save error to host_error for later use */ host_error = getaddrinfo(ipname, NULL, &req, &ai); if (host_error != 0) return host_error; + *name = g_strdup(ai->ai_canonname); - if (getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, - sizeof(hbuf), NULL, 0, 0)) - return 1; - - /*FIXME: how does this work? *name = g_strdup(ai->?);*/ freeaddrinfo(ai); - return 1; #else hp = gethostbyaddr(ipname, strlen(ipname), AF_INET); if (hp == NULL) return -1;