[MPlayer-dev-eng] [PATCH] Don't try to connect to AF_INET address with AF_INET6
Aaron Plattner
aplattner at nvidia.com
Sat Jul 6 03:19:40 CEST 2013
When _BSD_SOURCE isn't defined, gethostbyname2() isn't available. This causes
HAVE_GETHOSTBYNAME2 to be undefined, making connect2Server_with_af fall back to
gethostbyname(), which always returns an AF_INET address.
Without a check against hp->h_addrtype, this causes the memcpy to stuff the 4
bytes of the AF_INET address into the beginning of the AF_INET6 address field:
Playing http://www.facebook.com/.
Resolving www.facebook.com for AF_INET6...
Connecting to server www.facebook.com[45ab:ed14::]: 80...
Failed to connect to server with AF_INET6
Resolving www.facebook.com for AF_INET...
Connecting to server www.facebook.com[69.171.237.20]: 80...
On systems with real IPv6 connections, this first connection attempt to a bogus
address can take a very long time to time out.
To address this problem, bail out immediately if gethostbyname() returns an
address from an incompatible family. The caller will immediately fallback to
AF_INET.
This patch is against SVN r36350.
Index: stream/tcp.c
===================================================================
--- stream/tcp.c (revision 36350)
+++ stream/tcp.c (working copy)
@@ -160,6 +160,8 @@
return TCP_ERROR_FATAL;
}
+ if (af != hp->h_addrtype) return TCP_ERROR_FATAL;
+
memcpy( our_s_addr, hp->h_addr_list[0], hp->h_length );
}
#if HAVE_WINSOCK2_H
More information about the MPlayer-dev-eng
mailing list