This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Incorrect addrlen when calling connect
- From: "David Bartley" <dtbartle at csclub dot uwaterloo dot ca>
- To: libc-alpha at sourceware dot org
- Date: Sat, 21 Jun 2008 01:50:36 -0400
- Subject: [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);