Commit 7f5583ae authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

ws2_32: Set length on successful return from WSAStringToAddress.

parent d4d7c263
...@@ -5953,6 +5953,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString, ...@@ -5953,6 +5953,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
res = WSAEFAULT; res = WSAEFAULT;
break; break;
} }
*lpAddressLength = sizeof(SOCKADDR_IN);
memset(lpAddress, 0, sizeof(SOCKADDR_IN)); memset(lpAddress, 0, sizeof(SOCKADDR_IN));
((LPSOCKADDR_IN)lpAddress)->sin_family = AF_INET; ((LPSOCKADDR_IN)lpAddress)->sin_family = AF_INET;
...@@ -5990,6 +5991,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString, ...@@ -5990,6 +5991,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
break; break;
} }
#ifdef HAVE_INET_PTON #ifdef HAVE_INET_PTON
*lpAddressLength = sizeof(SOCKADDR_IN6);
memset(lpAddress, 0, sizeof(SOCKADDR_IN6)); memset(lpAddress, 0, sizeof(SOCKADDR_IN6));
((LPSOCKADDR_IN6)lpAddress)->sin6_family = WS_AF_INET6; ((LPSOCKADDR_IN6)lpAddress)->sin6_family = WS_AF_INET6;
......
...@@ -1801,8 +1801,9 @@ static void test_WSAStringToAddressA(void) ...@@ -1801,8 +1801,9 @@ static void test_WSAStringToAddressA(void)
static void test_WSAStringToAddressW(void) static void test_WSAStringToAddressW(void)
{ {
INT ret, len; INT ret, len;
SOCKADDR_IN sockaddr; SOCKADDR_IN sockaddr, *sin;
SOCKADDR_IN6 sockaddr6; SOCKADDR_IN6 sockaddr6;
SOCKADDR_STORAGE sockaddr_storage;
int GLE; int GLE;
WCHAR address1[] = { '0','.','0','.','0','.','0', 0 }; WCHAR address1[] = { '0','.','0','.','0','.','0', 0 };
...@@ -1866,6 +1867,20 @@ static void test_WSAStringToAddressW(void) ...@@ -1866,6 +1867,20 @@ static void test_WSAStringToAddressW(void)
(ret == SOCKET_ERROR && (GLE == ERROR_INVALID_PARAMETER || GLE == WSAEINVAL)), (ret == SOCKET_ERROR && (GLE == ERROR_INVALID_PARAMETER || GLE == WSAEINVAL)),
"WSAStringToAddressW() failed unexpectedly: %d\n", GLE ); "WSAStringToAddressW() failed unexpectedly: %d\n", GLE );
/* Test with a larger buffer than necessary */
len = sizeof(sockaddr_storage);
sin = (SOCKADDR_IN *)&sockaddr_storage;
sin->sin_port = 0;
sin->sin_addr.s_addr = 0;
ret = WSAStringToAddressW( address5, AF_INET, NULL, (SOCKADDR*)sin, &len );
ok( (ret == 0 && sin->sin_addr.s_addr == 0xffffffff && sin->sin_port == 0xffff) ||
(ret == SOCKET_ERROR && (GLE == ERROR_INVALID_PARAMETER || GLE == WSAEINVAL)),
"WSAStringToAddressW() failed unexpectedly: %d\n", GLE );
ok( len == sizeof(SOCKADDR_IN) ||
broken(len == sizeof(SOCKADDR_STORAGE)) /* NT4/2k */,
"unexpected length %d\n", len );
len = sizeof(sockaddr6); len = sizeof(sockaddr6);
memset(&sockaddr6, 0, len); memset(&sockaddr6, 0, len);
sockaddr6.sin6_family = AF_INET6; sockaddr6.sin6_family = AF_INET6;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment