From eab59e84ace3e279af5fe9aab3ad48e2810bd16e Mon Sep 17 00:00:00 2001 From: Jeff Latimer Date: Fri, 17 Apr 2009 14:30:53 +1000 Subject: [PATCH] ws2_32: WSAAddressToStringW should return length of unicode address string should and include the trailing null. --- dlls/ws2_32/socket.c | 3 ++- dlls/ws2_32/tests/sock.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 1bcff894620..932483325c8 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4868,7 +4868,7 @@ INT WINAPI WSAAddressToStringW( LPSOCKADDR sockaddr, DWORD len, p = strchrW( buffer, ':' ); if (!((SOCKADDR_IN *)sockaddr)->sin_port) *p = 0; - size = strlenW( buffer ); + size = strlenW( buffer ) + 1; if (*lenstr < size) { @@ -4876,6 +4876,7 @@ INT WINAPI WSAAddressToStringW( LPSOCKADDR sockaddr, DWORD len, return SOCKET_ERROR; } + *lenstr = size; lstrcpyW( string, buffer ); return 0; } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index eb76a8651ea..cd88b8dd25d 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1369,6 +1369,7 @@ static void test_WSAAddressToStringW(void) ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() ); ok( !lstrcmpW( address, expect1 ), "Expected different address string\n" ); + ok( len == sizeof( expect1 )/sizeof( WCHAR ), "Expected size to be %d, got %d\n", sizeof( expect1 )/sizeof( WCHAR ), len); len = sizeof(address); @@ -1402,6 +1403,7 @@ static void test_WSAAddressToStringW(void) ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() ); ok( !lstrcmpW( address, expect4 ), "Expected different address string\n" ); + ok( len == sizeof( expect4 )/sizeof( WCHAR ), "Expected size to be %d, got %d\n", sizeof( expect4 )/sizeof( WCHAR ), len); } static void test_WSAStringToAddressA(void) -- 2.11.4.GIT