[PATCH 3/6] ws2_32: Cap the negotiated winsock version to 1.1 or 2.2.

Zebediah Figura zfigura at codeweavers.com
Tue Feb 1 00:20:48 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/ws2_32/socket.c         | 8 +++++++-
 dlls/ws2_32/tests/protocol.c | 3 +--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 23140529b24..565f1c89dc0 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -578,7 +578,13 @@ int WINAPI WSAStartup( WORD version, WSADATA *data )
 
     if (data)
     {
-        data->wVersion = version;
+        if (!LOBYTE(version) || LOBYTE(version) > 2
+                || (LOBYTE(version) == 2 && HIBYTE(version) > 2))
+            data->wVersion = MAKEWORD(2, 2);
+        else if (LOBYTE(version) == 1 && HIBYTE(version) > 1)
+            data->wVersion = MAKEWORD(1, 1);
+        else
+            data->wVersion = version;
         data->wHighVersion = MAKEWORD(2, 2);
         strcpy( data->szDescription, "WinSock 2.0" );
         strcpy( data->szSystemStatus, "Running" );
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index f859ad40e30..db89febff2e 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -2851,8 +2851,7 @@ static void test_startup(void)
         data.lpVendorInfo = (void *)0xdeadbeef;
         ret = WSAStartup(tests[i].version, &data);
         ok(ret == (LOBYTE(tests[i].version) ? 0 : WSAVERNOTSUPPORTED), "got %d\n", ret);
-        todo_wine_if (tests[i].version != tests[i].ret_version)
-            ok(data.wVersion == tests[i].ret_version, "got version %#x\n", data.wVersion);
+        ok(data.wVersion == tests[i].ret_version, "got version %#x\n", data.wVersion);
         if (!ret)
         {
             ret = WSAStartup(tests[i].version, &data);
-- 
2.34.1




More information about the wine-devel mailing list