projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged from silc_1_0_branch.
[silc.git]
/
apps
/
irssi
/
src
/
core
/
network.c
diff --git
a/apps/irssi/src/core/network.c
b/apps/irssi/src/core/network.c
index 6b2ceab4c50ea3fa6ebb2b141a884656044b38a7..bb46dd54fcd9f0e5ee51aac3507f571acffb89e6 100644
(file)
--- a/
apps/irssi/src/core/network.c
+++ b/
apps/irssi/src/core/network.c
@@
-468,18
+468,19
@@
int net_gethostbyaddr(IPADDR *ip, char **name)
#ifdef HAVE_IPV6
struct addrinfo req, *ai;
int host_error;
#ifdef HAVE_IPV6
struct addrinfo req, *ai;
int host_error;
+ char hostname[NI_MAXHOST];
+ char ipname[MAX_IP_LEN];
#else
struct hostent *hp;
#endif
#else
struct hostent *hp;
#endif
- char ipname[MAX_IP_LEN];
g_return_val_if_fail(ip != NULL, -1);
g_return_val_if_fail(name != NULL, -1);
g_return_val_if_fail(ip != NULL, -1);
g_return_val_if_fail(name != NULL, -1);
- net_ip2host(ip, ipname);
-
*name = NULL;
#ifdef HAVE_IPV6
*name = NULL;
#ifdef HAVE_IPV6
+ net_ip2host(ip, ipname);
+
memset(&req, 0, sizeof(struct addrinfo));
req.ai_socktype = SOCK_STREAM;
req.ai_flags = AI_CANONNAME;
memset(&req, 0, sizeof(struct addrinfo));
req.ai_socktype = SOCK_STREAM;
req.ai_flags = AI_CANONNAME;
@@
-488,11
+489,19
@@
int net_gethostbyaddr(IPADDR *ip, char **name)
host_error = getaddrinfo(ipname, NULL, &req, &ai);
if (host_error != 0)
return host_error;
host_error = getaddrinfo(ipname, NULL, &req, &ai);
if (host_error != 0)
return host_error;
- *name = g_strdup(ai->ai_canonname);
+ host_error = getnameinfo(ai->ai_addr, ai->ai_addrlen,
+ hostname, NI_MAXHOST, NULL, 0, 0);
+ if (host_error != 0) {
+ freeaddrinfo(ai);
+ return host_error;
+ }
+
+ *name = g_strdup(hostname);
freeaddrinfo(ai);
#else
freeaddrinfo(ai);
#else
- hp = gethostbyaddr(ipname, strlen(ipname), AF_INET);
+ if (ip->family != AF_INET) return -1;
+ hp = gethostbyaddr(&ip->ip, 4, AF_INET);
if (hp == NULL) return -1;
*name = g_strdup(hp->h_name);
if (hp == NULL) return -1;
*name = g_strdup(hp->h_name);