This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
sysdeps/posix/getaddrinfo.c incorrectly checks for sa_len
- From: "Neal H. Walfield" <neal at walfield dot org>
- To: libc-alpha at sources dot redhat dot com
- Date: Tue, 17 May 2005 12:33:00 +0100
- Subject: sysdeps/posix/getaddrinfo.c incorrectly checks for sa_len
sysdeps/posix/getaddrinfo.c incorrectly checks for sa_len. It should
check if _HAVE_SA_LEN is defined, not if SALEN is true as is done in,
for example, sysdeps/generic/ifreq.h .
I encountered this while debugging the Orbit2 test suite on the Hurd.
It checks if two addresses are the same using the following idiom:
const struct sockaddr *saddr;
struct addrinfo hints, *result = NULL;
...
getaddrinfo(link_get_local_hostname(), NULL, &hints, &local _addr) != 0)
...
if (af == AF_INET) {
if (!memcmp ((struct sockaddr_in *)result->ai_addr,
(struct sockaddr_in *)saddr,
result->ai_addrlen))
I've attached a patch which should fix the problem.
Thanks,
Neal
2005-05-17 Neal H. Walfield <neal@gnu.org>
* sysdeps/posix/getaddrinfo.c (gaih_local): Check if _HAVE_SA_LEN
is defined, not if SALEN.
(gaih_inet): Likewise.
--- ./sysdeps/posix/getaddrinfo.c.orig 2005-05-17 12:16:21.000000000 +0100
+++ ./sysdeps/posix/getaddrinfo.c 2005-05-17 12:30:13.000000000 +0100
@@ -193,10 +193,10 @@ gaih_local (const char *name, const stru
(*pai)->ai_addrlen = sizeof (struct sockaddr_un);
(*pai)->ai_addr = (void *) (*pai) + sizeof (struct addrinfo);
-#if SALEN
+#ifdef _HAVE_SA_LEN
((struct sockaddr_un *) (*pai)->ai_addr)->sun_len =
sizeof (struct sockaddr_un);
-#endif /* SALEN */
+#endif /* _HAVE_SA_LEN */
((struct sockaddr_un *)(*pai)->ai_addr)->sun_family = AF_LOCAL;
memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
@@ -859,9 +859,9 @@ gaih_inet (const char *name, const struc
(*pai)->ai_canonname = canon;
canon = NULL;
-#if SALEN
+#ifdef _HAVE_SA_LEN
(*pai)->ai_addr->sa_len = socklen;
-#endif /* SALEN */
+#endif /* _HAVE_SA_LEN */
(*pai)->ai_addr->sa_family = family;
if (family == AF_INET6)