Zebediah Figura : ws2_32: Cap the negotiated winsock version to 1.1 or 2.2.

Alexandre Julliard julliard at winehq.org
Tue Feb 1 15:21:34 CST 2022


Module: wine
Branch: master
Commit: e078f698815ea160ee78b49f2c9679d3607e998d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e078f698815ea160ee78b49f2c9679d3607e998d

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Tue Feb  1 00:20:48 2022 -0600

ws2_32: Cap the negotiated winsock version to 1.1 or 2.2.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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);




More information about the wine-cvs mailing list