Commit 4028a0e9 authored by Jeff Latimer's avatar Jeff Latimer Committed by Alexandre Julliard

ws2_32: Add the port to the IPv6 address string if present.

parent 4814d67e
......@@ -4958,12 +4958,17 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
{
struct WS_sockaddr_in6 *sockaddr6 = (LPSOCKADDR_IN6) sockaddr;
buffer[0] = 0;
if (len < sizeof(SOCKADDR_IN6)) return SOCKET_ERROR;
if (!WS_inet_ntop(WS_AF_INET6, &sockaddr6->sin6_addr, buffer, sizeof(buffer)))
if ((sockaddr6->sin6_port))
strcpy(buffer, "[");
if (!WS_inet_ntop(WS_AF_INET6, &sockaddr6->sin6_addr, buffer+strlen(buffer), sizeof(buffer)))
{
WSASetLastError(WSAEINVAL);
return SOCKET_ERROR;
}
if ((sockaddr6->sin6_port))
sprintf(buffer+strlen(buffer), "]:%u", ntohs(sockaddr6->sin6_port));
break;
}
......
......@@ -1429,11 +1429,8 @@ static void test_WSAAddressToStringA(void)
ret = WSAAddressToStringA( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
ok( !ret, "WSAAddressToStringA() failed unexpectedly: %d\n", WSAGetLastError() );
todo_wine
{
ok( !strcmp( address6, expect6_3 ), "Expected: %s, got: %s\n", expect6_3, address6 );
ok( len == sizeof(expect6_3), "Got size %d\n", len);
}
/* Test IPv6 address, port number and scope_id */
len = sizeof(address6);
......@@ -1603,11 +1600,8 @@ static void test_WSAAddressToStringW(void)
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
todo_wine
{
ok( !lstrcmpW( address6, expect6_3 ), "Wrong string returned\n" );
ok( len == sizeof(expect6_3)/sizeof(WCHAR), "Got %d\n", len);
}
/* Test IPv6 address, port number and scope_id */
len = sizeof(address6)/sizeof(WCHAR);
......
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