diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-09-27 00:04:12 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-09-27 00:04:12 +0800 |
commit | 2e42040bad4c8998c7c2aef3f5f34db2730245a6 (patch) | |
tree | 686fc3e3d897c50195b60518f8c81acd29227492 | |
parent | 99c61843f0d1da7f9b3b73b99bab0e918ce99e5b (diff) | |
download | gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.gz gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.bz2 gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.lz gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.xz gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.zst gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.zip |
IPv6 implementation rewritten to use getnameinfo() which is the proper
2003-09-26 Jeffrey Stedfast <fejj@ximian.com>
* e-host-utils.c (e_gethostbyaddr_r): IPv6 implementation
rewritten to use getnameinfo() which is the proper function to use
in this case. Fixes bug #46006 the Right Way (tm).
svn path=/trunk/; revision=22720
-rw-r--r-- | e-util/ChangeLog | 6 | ||||
-rw-r--r-- | e-util/e-host-utils.c | 49 |
2 files changed, 11 insertions, 44 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 38ee4c5d26..1fc1f8d1d3 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,9 @@ +2003-09-26 Jeffrey Stedfast <fejj@ximian.com> + + * e-host-utils.c (e_gethostbyaddr_r): IPv6 implementation + rewritten to use getnameinfo() which is the proper function to use + in this case. Fixes bug #46006 the Right Way (tm). + 2003-09-25 Jeffrey Stedfast <fejj@ximian.com> * e-host-utils.c (e_gethostbyaddr_r): Make sure that diff --git a/e-util/e-host-utils.c b/e-util/e-host-utils.c index 1d685019cc..c4057113df 100644 --- a/e-util/e-host-utils.c +++ b/e-util/e-host-utils.c @@ -291,47 +291,18 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host char *buf, size_t buflen, int *herr) { #ifdef ENABLE_IPv6 - struct addrinfo hints, *res; - const char *name; int retval, len; - if ((name = inet_ntop (type, addr, buf, buflen)) == NULL) { - if (errno == ENOSPC) - return ERANGE; - - return -1; - } - - memset (&hints, 0, sizeof (struct addrinfo)); - hints.ai_flags = AI_CANONNAME; - hints.ai_family = type == AF_INET6 ? PF_INET6 : PF_INET; - hints.ai_socktype = 0; - hints.ai_protocol = 0; - - if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) { + if ((retval = getnameinfo (addr, addrlen, buf, buflen, NULL, 0, NI_NAMEREQD)) != 0) { *herr = ai_to_herr (retval); return -1; } - /* If nodename is not null, and if requested by the AI_CANONNAME flag, the ai_canonname - * field of the first returned addrinfo structure shall point to a null-terminated - * string containing the canonical name corresponding to the input nodename; if the - * canonical name is not available, then ai_canonname shall refer to the nodename - * argument or a string with the same contents. - * - * Note: NetBSD seems to set res->ai_canonname to NULL in this case instead. - */ - if (!res->ai_canonname || !strcmp (res->ai_canonname, name)) { - *herr = HOST_NOT_FOUND; - return -1; - } - - len = ALIGN (strlen (res->ai_canonname) + 1); - if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *)) + len = ALIGN (strlen (buf) + 1); + if (buflen < IPv6_BUFLEN_MIN + len + addrlen + sizeof (char *)) return ERANGE; /* h_name */ - strcpy (buf, res->ai_canonname); host->h_name = buf; buf += len; @@ -341,16 +312,8 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host buf += sizeof (char *); /* h_addrtype and h_length */ - host->h_length = res->ai_addrlen; - if (res->ai_family == PF_INET6) { - host->h_addrtype = AF_INET6; - - addr = (char *) &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; - } else { - host->h_addrtype = AF_INET; - - addr = (char *) &((struct sockaddr_in *) res->ai_addr)->sin_addr; - } + host->h_length = addrlen; + host->h_addrtype = type; memcpy (buf, addr, host->h_length); addr = buf; @@ -361,8 +324,6 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host ((char **) buf)[1] = NULL; host->h_addr_list = (char **) buf; - freeaddrinfo (res); - return 0; #else /* No support for IPv6 addresses */ #ifdef HAVE_GETHOSTBYADDR_R |