From 1805dc67b0f981cb70c785d057bdf8d4c9427575 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Thu, 8 Dec 2011 19:21:01 +0000 Subject: [PATCH] [WS2_32] - Use size of struct instead of size of pointer. Don't copy szProtocol, because it's set later. CID 14129 and 54. svn path=/trunk/; revision=54615 --- reactos/dll/win32/ws2_32/misc/ns.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/ws2_32/misc/ns.c b/reactos/dll/win32/ws2_32/misc/ns.c index 5089a0abf6e..6370b0f108e 100644 --- a/reactos/dll/win32/ws2_32/misc/ns.c +++ b/reactos/dll/win32/ws2_32/misc/ns.c @@ -401,7 +401,7 @@ WSAStringToAddressA(IN LPSTR AddressString, memcpy(lpProtoInfoW, lpProtocolInfo, - sizeof(LPWSAPROTOCOL_INFOA)); + FIELD_OFFSET(WSAPROTOCOL_INFOA, szProtocol)); MultiByteToWideChar(CP_ACP, 0, @@ -427,7 +427,7 @@ WSAStringToAddressA(IN LPSTR AddressString, lpProtoInfoW); WSASetLastError(ret); - return ret; + return ret; } @@ -459,9 +459,9 @@ WSAStringToAddressW(IN LPWSTR AddressString, /* Set right adress family */ if (lpProtocolInfo!=NULL) - sockaddr->sin_family = lpProtocolInfo->iAddressFamily; - - else sockaddr->sin_family = AddressFamily; + sockaddr->sin_family = lpProtocolInfo->iAddressFamily; + else + sockaddr->sin_family = AddressFamily; /* Report size */ if (AddressFamily == AF_INET) @@ -513,7 +513,7 @@ WSAStringToAddressW(IN LPWSTR AddressString, WSASetLastError(res); if (!res) return 0; - return SOCKET_ERROR; + return SOCKET_ERROR; } void check_hostent(struct hostent **he) @@ -923,15 +923,14 @@ gethostbyname(IN CONST CHAR FAR* name) if(name == NULL) { ret = gethostname(p->Hostent->h_name, MAX_HOSTNAME_LEN); + if(ret) + { + WSASetLastError( WSAHOST_NOT_FOUND ); //WSANO_DATA ?? + return NULL; + } return p->Hostent; } - if(ret) - { - WSASetLastError( WSAHOST_NOT_FOUND ); //WSANO_DATA ?? - return NULL; - } - /* Is it an IPv6 address? */ found = strstr(name, ":"); if( found != NULL )