Torge Matthies : ws2_32/tests: Test short fd_set with select().

Alexandre Julliard julliard at winehq.org
Sun Dec 26 10:44:21 CST 2021


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

Author: Torge Matthies <openglfreak at googlemail.com>
Date:   Fri Dec 24 01:51:30 2021 +0100

ws2_32/tests: Test short fd_set with select().

Signed-off-by: Torge Matthies <openglfreak at googlemail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/sock.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 02713a7c625..d1cefd5eccc 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3152,7 +3152,7 @@ static void test_select(void)
     static char tmp_buf[1024];
 
     SOCKET fdListen, fdRead, fdWrite;
-    fd_set readfds, writefds, exceptfds;
+    fd_set readfds, writefds, exceptfds, *alloc_readfds;
     unsigned int maxfd;
     int ret, len;
     char buffer;
@@ -3160,7 +3160,8 @@ static void test_select(void)
     struct sockaddr_in address;
     select_thread_params thread_params;
     HANDLE thread_handle;
-    DWORD ticks, id;
+    DWORD ticks, id, old_protect;
+    char *page_pair;
 
     fdRead = socket(AF_INET, SOCK_STREAM, 0);
     ok( (fdRead != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() );
@@ -3326,6 +3327,15 @@ static void test_select(void)
     ok(FD_ISSET(fdWrite, &readfds), "fdWrite socket is not in the set\n");
     ok(FD_ISSET(fdRead, &readfds), "fdRead socket is not in the set\n");
 
+    page_pair = VirtualAlloc(NULL, 0x1000 * 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+    VirtualProtect(page_pair + 0x1000, 0x1000, PAGE_NOACCESS, &old_protect);
+    alloc_readfds = (fd_set *)((page_pair + 0x1000) - offsetof(fd_set, fd_array[1]));
+    alloc_readfds->fd_count = 1;
+    alloc_readfds->fd_array[0] = fdRead;
+    ret = select(fdRead+1, alloc_readfds, NULL, NULL, &select_timeout);
+    ok(ret == 1, "select returned %d\n", ret);
+    VirtualFree(page_pair, 0, MEM_RELEASE);
+
     closesocket(fdRead);
     closesocket(fdWrite);
 




More information about the wine-cvs mailing list