[PATCH] ws2_32: Fix return values of WSCGetProviderPath() stub
Aaro Altonen
a.altonen at hotmail.com
Tue Feb 25 11:06:09 CST 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45801
Signed-off-by: Aaro Altonen <a.altonen at hotmail.com>
---
dlls/ws2_32/socket.c | 17 +++++++++++++----
dlls/ws2_32/tests/sock.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index c284f595ab..700e93894d 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -9006,12 +9006,21 @@ INT WINAPI WSCEnableNSProvider( LPGUID provider, BOOL enable )
*/
INT WINAPI WSCGetProviderPath( LPGUID provider, LPWSTR path, LPINT len, LPINT errcode )
{
- FIXME( "(%s %p %p %p) Stub!\n", debugstr_guid(provider), path, len, errcode );
+ if (!provider || !len || !path) {
+ if (errcode)
+ *errcode = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
- if (!errcode || !provider || !len) return WSAEFAULT;
+ if (*len <= 0) {
+ if (errcode)
+ *errcode = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
- *errcode = WSAEINVAL;
- return SOCKET_ERROR;
+ FIXME("WSCGetProviderPath not implemented.\n");
+
+ return 0;
}
/***********************************************************************
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 60c5dfc63f..176a19bcfa 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -84,6 +84,7 @@ static int (WINAPI *pWSALookupServiceNextW)(HANDLE,DWORD,LPDWORD,LPWSAQUERYSET
static int (WINAPI *pWSAEnumNameSpaceProvidersA)(LPDWORD,LPWSANAMESPACE_INFOA);
static int (WINAPI *pWSAEnumNameSpaceProvidersW)(LPDWORD,LPWSANAMESPACE_INFOW);
static int (WINAPI *pWSAPoll)(WSAPOLLFD *,ULONG,INT);
+static int (WINAPI *pWSCGetProviderPath)(LPGUID, LPWSTR, LPINT, LPINT);
/* Function pointers from iphlpapi */
static DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO,PULONG);
@@ -1300,6 +1301,7 @@ static void Init (void)
pWSAEnumNameSpaceProvidersA = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersA");
pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW");
pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll");
+ pWSCGetProviderPath = (void *)GetProcAddress(hws2_32, "WSCGetProviderPath");
hiphlpapi = LoadLibraryA("iphlpapi.dll");
if (hiphlpapi)
@@ -10600,6 +10602,39 @@ static void test_address_list_query(void)
closesocket(s);
}
+static void test_WSCGetProviderPath(void)
+{
+ GUID ProviderIdIP = { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x00, 0x0, 0x0, 0x0, 0x0, 0x0 } };
+ wchar_t buffer[256];
+ INT ret, err, len;
+
+ ret = pWSCGetProviderPath(NULL, NULL, NULL, NULL);
+ ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+
+ ret = pWSCGetProviderPath(&ProviderIdIP, NULL, NULL, NULL);
+ ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+
+ 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);
+
+ ret = pWSCGetProviderPath(&ProviderIdIP, NULL, NULL, &err);
+ ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+ ok(err == WSAEFAULT, "Got unexpected error %d.\n", err);
+
+ len = -1;
+ ret = pWSCGetProviderPath(&ProviderIdIP, buffer, &len, &err);
+ ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+ ok(err == WSAEFAULT, "Got unexpected error %d.\n", err);
+
+ /* WSCGetProviderPath() will return an error but if "ProviderIdIP"
+ * was valid, its path's length is written to "len" */
+ len = -1;
+ ret = pWSCGetProviderPath(&ProviderIdIP, NULL, &len, &err);
+ ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+ ok(err == WSAEFAULT, "Got unexpected error %d.\n", err);
+}
+
static DWORD WINAPI inet_ntoa_thread_proc(void *param)
{
ULONG addr;
@@ -11681,6 +11716,8 @@ START_TEST( sock )
test_completion_port();
test_address_list_query();
+ test_WSCGetProviderPath();
+
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
test_send();
test_synchronous_WSAIoctl();
--
2.25.1
More information about the wine-devel
mailing list