This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Incorrect addrlen when calling connect


Hi,

In resolv/res_send.c, connect may be passed a 'struct sockaddr_in'
although the addrlen will always be sizeof(struct sockaddr_in6). The
attached patch fixes this by setting the addrlen according to
nsap->sin6_family, as done elsewhere in this file already.

-- David
--- resolv/res_send.c.orig	2008-06-21 01:37:47.353276768 -0400
+++ resolv/res_send.c	2008-06-21 01:38:14.092937605 -0400
@@ -943,7 +943,9 @@
 		 * the absence of a nameserver without timing out.
 		 */
 		if (connect(EXT(statp).nssocks[ns], (struct sockaddr *)nsap,
-			    sizeof *nsap) < 0) {
+			    nsap->sin6_family == AF_INET
+			    ? sizeof (struct sockaddr_in)
+			    : sizeof (struct sockaddr_in6)) < 0) {
 			Aerror(statp, stderr, "connect(dg)", errno,
 			       (struct sockaddr *) nsap);
 			__res_iclose(statp, false);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]