* net.cc (cygwin_getaddrinfo): Fix a comment. Only memset whints if

hints is NULL.  Add a comment and set whints.ai_family explicitely to
	AF_UNSPEC to follow glibc man page closely.  Check flags against whints
	for locality.
This commit is contained in:
Corinna Vinschen 2013-11-19 18:07:46 +00:00
parent 705b50fe39
commit 0732e52c41
2 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2013-11-19 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_getaddrinfo): Fix a comment. Only memset whints if
hints is NULL. Add a comment and set whints.ai_family explicitely to
AF_UNSPEC to follow glibc man page closely. Check flags against whints
for locality.
2013-11-19 Corinna Vinschen <corinna@vinschen.de> 2013-11-19 Corinna Vinschen <corinna@vinschen.de>
* wincap.cc (wincapc::init): Fix dwMinorVersion for Windows 8.1 and * wincap.cc (wincapc::init): Fix dwMinorVersion for Windows 8.1 and

View File

@ -3294,9 +3294,8 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
| AI_NUMERICSERV | AI_ADDRCONFIG | AI_V4MAPPED | AI_NUMERICSERV | AI_ADDRCONFIG | AI_V4MAPPED
| AI_IDN_MASK))) | AI_IDN_MASK)))
return EAI_BADFLAGS; return EAI_BADFLAGS;
/* AI_NUMERICSERV is not supported in our replacement getaddrinfo, nor /* AI_NUMERICSERV is not supported prior to Windows Vista. We just check
is it supported by WinSock prior to Vista. We just check the servname the servname parameter by ourselves here. */
parameter by ourselves here. */
if (hints && (hints->ai_flags & AI_NUMERICSERV)) if (hints && (hints->ai_flags & AI_NUMERICSERV))
{ {
char *p; char *p;
@ -3341,9 +3340,13 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
return EAI_MEMORY; return EAI_MEMORY;
} }
memset (&whints, 0, sizeof whints);
if (!hints) if (!hints)
whints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; {
/* Default settings per glibc man page. */
memset (&whints, 0, sizeof whints);
whints.ai_family = PF_UNSPEC;
whints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
}
else else
{ {
/* sizeof addrinfo == sizeof addrinfoW */ /* sizeof addrinfo == sizeof addrinfoW */
@ -3355,8 +3358,8 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
apparently for performance reasons. To get the POSIX default apparently for performance reasons. To get the POSIX default
behaviour, the AI_ALL flag has to be set. */ behaviour, the AI_ALL flag has to be set. */
if (wincap.supports_all_posix_ai_flags () if (wincap.supports_all_posix_ai_flags ()
&& hints->ai_family == PF_UNSPEC && whints.ai_family == PF_UNSPEC
&& !(hints->ai_flags & AI_ADDRCONFIG)) && !(whints.ai_flags & AI_ADDRCONFIG))
whints.ai_flags |= AI_ALL; whints.ai_flags |= AI_ALL;
} }
/* Disable automatic IDN conversion on W8 and later. */ /* Disable automatic IDN conversion on W8 and later. */