Re: [evolution-patches] fix for the second half of bug #46006, getaddrinfo suckage
- From: Jeffrey Stedfast <fejj ximian com>
- To: Dan Winship <danw ximian com>
- Cc: evolution-patches ximian com
- Subject: Re: [evolution-patches] fix for the second half of bug #46006, getaddrinfo suckage
- Date: Fri, 26 Sep 2003 11:52:38 -0400
yep, you'd be right. turns out the correct function to be using is
getnameinfo().
new patch attached.
On Thu, 2003-09-25 at 12:23, Dan Winship wrote:
> > http://www.opengroup.org/onlinepubs/007904975/functions/getaddrinfo.html
>
> A numeric host address string is not a ``name'', and thus does
> not have a ``canonical name'' form; no address to host name
> translation is performed.
>
> So it looks like it shouldn't even be calling getaddrinfo in that case.
>
> -- Dan
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
--
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com - www.ximian.com
? 46006-2.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.398.2.6
diff -u -r1.398.2.6 ChangeLog
--- ChangeLog 4 Jan 1997 06:07:00 -0000 1.398.2.6
+++ ChangeLog 26 Sep 2003 15:51:10 -0000
@@ -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.
+
2003-09-04 Dan Winship <danw ximian com>
* Makefile.am: Kill off libeconduit-static: it was only needed for
Index: e-host-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-host-utils.c,v
retrieving revision 1.14
diff -u -r1.14 e-host-utils.c
--- e-host-utils.c 29 Apr 2003 02:14:37 -0000 1.14
+++ e-host-utils.c 26 Sep 2003 15:51:10 -0000
@@ -291,34 +291,18 @@
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;
}
- 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;
@@ -328,16 +312,8 @@
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;
@@ -347,8 +323,6 @@
((char **) buf)[0] = addr;
((char **) buf)[1] = NULL;
host->h_addr_list = (char **) buf;
-
- freeaddrinfo (res);
return 0;
#else /* No support for IPv6 addresses */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]