From 4028a0e9f06e5342d127bdca673c4793804e974a Mon Sep 17 00:00:00 2001 From: Jeff Latimer Date: Tue, 28 Jul 2009 19:39:42 +1000 Subject: [PATCH] ws2_32: Add the port to the IPv6 address string if present. --- dlls/ws2_32/socket.c | 7 ++++++- dlls/ws2_32/tests/sock.c | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index a60152195f0..b4df86ffb69 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -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; } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index b1b85fe350a..44ed183679f 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -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);