ws2_32: Use the correct address family in gethostbyaddr
Bruno Jesus
00cpxxx at gmail.com
Mon Apr 14 22:43:53 CDT 2014
AF_INET6 is defined as 23 in Windows and 10 in Linux and it's also
different in BSD. Ensure that wherever the socket family is
used/returned it is converted as expected. I'm preserving the original
variable as it's used for tracing in the function.
Best wishes,
Bruno
-------------- next part --------------
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index fe85356..54e7e2f 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -5084,6 +5084,7 @@ struct WS_hostent* WINAPI WS_gethostbyaddr(const char *addr, int len, int type)
{
struct WS_hostent *retval = NULL;
struct hostent* host;
+ int unixtype = convert_af_w2u(type);
#ifdef HAVE_LINUX_GETHOSTBYNAME_R_6
char *extrabuf;
@@ -5093,7 +5094,7 @@ struct WS_hostent* WINAPI WS_gethostbyaddr(const char *addr, int len, int type)
host = NULL;
extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
while(extrabuf) {
- int res = gethostbyaddr_r(addr, len, type,
+ int res = gethostbyaddr_r(addr, len, unixtype,
&hostentry, extrabuf, ebufsize, &host, &locerr);
if( res != ERANGE) break;
ebufsize *=2;
@@ -5102,7 +5103,7 @@ struct WS_hostent* WINAPI WS_gethostbyaddr(const char *addr, int len, int type)
if (!host) SetLastError((locerr < 0) ? wsaErrno() : wsaHerrno(locerr));
#else
EnterCriticalSection( &csWSgetXXXbyYYY );
- host = gethostbyaddr(addr, len, type);
+ host = gethostbyaddr(addr, len, unixtype);
if (!host) SetLastError((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
#endif
if( host != NULL ) retval = WS_dup_he(host);
@@ -6408,7 +6409,7 @@ static struct WS_hostent *WS_dup_he(const struct hostent* p_he)
p_to = WS_create_he(p_he->h_name, i + 1, alias_size, addresses + 1, p_he->h_length);
if (!p_to) return NULL;
- p_to->h_addrtype = p_he->h_addrtype;
+ p_to->h_addrtype = convert_af_u2w(p_he->h_addrtype);
p_to->h_length = p_he->h_length;
for(i = 0, p = p_to->h_addr_list[0]; p_he->h_addr_list[i]; i++, p += p_to->h_length)
More information about the wine-patches
mailing list