Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-06-23 16:35:31 +0400
committerCorinna Vinschen <corinna@vinschen.de>2014-06-23 16:35:31 +0400
commit4ea38ac7efd250e716caa2eff26fec7707595520 (patch)
tree98cf696f1e9bc4217e09e4ea79afa87e115ec536 /winsup/cygwin/net.cc
parent9c54570beb5a3681bc744fe574d659b8255055a0 (diff)
* net.cc (cygwin_getaddrinfo): Fix value of hint->ai_addrlen on 64 bit.
Explain why.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 010cf2435..67c68804a 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -3366,6 +3366,11 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
/* sizeof addrinfo == sizeof addrinfoW */
memcpy (&whints, hints, sizeof whints);
whints.ai_flags &= ~AI_IDN_MASK;
+#ifdef __x86_64__
+ /* ai_addrlen is socklen_t (4 bytes) in POSIX but size_t (8 bytes) in
+ Winsock. Sert upper 4 bytes explicitely to 0 to avoid EAI_FAIL. */
+ whints.ai_addrlen &= UINT32_MAX;
+#endif
/* AI_ADDRCONFIG is not supported prior to Vista. Rather it's
the default and only possible setting.
On Vista, the default behaviour is as if AI_ADDRCONFIG is set,
@@ -3402,6 +3407,11 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
/* sizeof addrinfo == sizeof addrinfoW */
memcpy (&whints, hints, sizeof whints);
whints.ai_family = AF_INET;
+#ifdef __x86_64__
+ /* ai_addrlen is socklen_t (4 bytes) in POSIX but size_t (8 bytes) in
+ Winsock. Sert upper 4 bytes explicitely to 0 to avoid EAI_FAIL. */
+ whints.ai_addrlen &= UINT32_MAX;
+#endif
int ret2 = w32_to_gai_err (GetAddrInfoW (whost, wserv, &whints, &wres));
if (!ret2)
{