From: Aaro Altonen a.altonen@hotmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45801 Signed-off-by: Aaro Altonen a.altonen@hotmail.com Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/ws2_32/socket.c | 17 +++++++++-- dlls/ws2_32/tests/sock.c | 62 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 4d2afa946b..b7a570043c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -8940,10 +8940,21 @@ INT WINAPI WSCGetProviderPath( LPGUID provider, LPWSTR path, LPINT len, LPINT er { FIXME( "(%s %p %p %p) Stub!\n", debugstr_guid(provider), path, len, errcode );
- if (!errcode || !provider || !len) return WSAEFAULT; + if (!provider || !len) + { + if (errcode) + *errcode = WSAEFAULT; + return SOCKET_ERROR; + }
- *errcode = WSAEINVAL; - return SOCKET_ERROR; + if (*len <= 0) + { + if (errcode) + *errcode = WSAEINVAL; + return SOCKET_ERROR; + } + + return 0; }
/*********************************************************************** diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index b523c326d6..c7f88d6f3b 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -86,6 +86,7 @@ static int (WINAPI *pWSAEnumNameSpaceProvidersA)(LPDWORD,LPWSANAMESPACE_INFOA) static int (WINAPI *pWSAEnumNameSpaceProvidersW)(LPDWORD,LPWSANAMESPACE_INFOW); static int (WINAPI *pWSAPoll)(WSAPOLLFD *,ULONG,INT); static int (WINAPI *pWSCGetProviderInfo)(LPGUID,WSC_PROVIDER_INFO_TYPE,PBYTE,size_t*,DWORD,LPINT); +static int (WINAPI *pWSCGetProviderPath)(LPGUID, LPWSTR, LPINT, LPINT);
/* Function pointers from iphlpapi */ static DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO,PULONG); @@ -1303,6 +1304,7 @@ static void Init (void) pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW"); pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll"); pWSCGetProviderInfo = (void *)GetProcAddress(hws2_32, "WSCGetProviderInfo"); + pWSCGetProviderPath = (void *)GetProcAddress(hws2_32, "WSCGetProviderPath");
hiphlpapi = LoadLibraryA("iphlpapi.dll"); if (hiphlpapi) @@ -11351,6 +11353,65 @@ static void test_WSCGetProviderInfo(void) ok(errcode == WSANO_RECOVERY, "got %d, expected WSANO_RECOVERY\n", errcode); }
+static void test_WSCGetProviderPath(void) +{ + GUID provider = {}; + WCHAR buffer[256]; + INT ret, err, len; + + if (!pWSCGetProviderPath) + { + skip("WSCGetProviderPath is not available.\n"); + return; + } + + ret = pWSCGetProviderPath(NULL, NULL, NULL, NULL); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + + ret = pWSCGetProviderPath(&provider, NULL, NULL, NULL); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + + ret = pWSCGetProviderPath(NULL, buffer, NULL, NULL); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + + len = -1; + ret = pWSCGetProviderPath(NULL, NULL, &len, NULL); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + ok(len == -1, "Got unexpected len %d.\n", len); + + err = 0; + ret = pWSCGetProviderPath(NULL, NULL, NULL, &err); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + ok(err == WSAEFAULT, "Got unexpected error %d.\n", err); + + err = 0; + ret = pWSCGetProviderPath(&provider, NULL, NULL, &err); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + ok(err == WSAEFAULT, "Got unexpected error %d.\n", err); + + err = 0; + len = -1; + ret = pWSCGetProviderPath(&provider, NULL, &len, &err); + ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + ok(err == WSAEINVAL, "Got unexpected error %d.\n", err); + ok(len == -1, "Got unexpected len %d.\n", len); + + err = 0; + len = 256; + ret = pWSCGetProviderPath(&provider, NULL, &len, &err); + todo_wine ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + todo_wine ok(err == WSAEINVAL, "Got unexpected error %d.\n", err); + ok(len == 256, "Got unexpected len %d.\n", len); + + /* Valid pointers and length but invalid GUID */ + err = 0; + len = 256; + ret = pWSCGetProviderPath(&provider, buffer, &len, &err); + todo_wine ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); + todo_wine ok(err == WSAEINVAL, "Got unexpected error %d.\n", err); + ok(len == 256, "Got unexpected len %d.\n", len); +} + START_TEST( sock ) { int i; @@ -11432,6 +11493,7 @@ START_TEST( sock ) test_address_list_query();
test_WSCGetProviderInfo(); + test_WSCGetProviderPath();
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */ test_send();