Henri Verbeet : ws2_32: Return WSAEINVAL if "out_size" is smaller than the minimum size for SIO_ADDRESS_LIST_QUERY.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Oct 6 15:19:11 CDT 2014


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Oct  3 09:19:22 2014 +0200

ws2_32: Return WSAEINVAL if "out_size" is smaller than the minimum size for SIO_ADDRESS_LIST_QUERY.

---

 dlls/ws2_32/socket.c     |  7 +++++++
 dlls/ws2_32/tests/sock.c | 12 ++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 75cf0f0..98ed686 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3937,6 +3937,13 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
             return SOCKET_ERROR;
         }
 
+        if (out_size && out_size < FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[0]))
+        {
+            *ret_size = 0;
+            WSASetLastError(WSAEINVAL);
+            return SOCKET_ERROR;
+        }
+
         if (GetAdaptersInfo(NULL, &size) == ERROR_BUFFER_OVERFLOW)
         {
             IP_ADAPTER_INFO *p, *table = HeapAlloc(GetProcessHeap(), 0, size);
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 4c93358..1d61f9a 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7498,6 +7498,18 @@ static void test_address_list_query(void)
     ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
     ok(WSAGetLastError() == WSAEFAULT, "Got unexpected error %d.\n", WSAGetLastError());
 
+    bytes_returned = 0xdeadbeef;
+    ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, address_list, 1, &bytes_returned, NULL, NULL);
+    ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+    ok(WSAGetLastError() == WSAEINVAL, "Got unexpected error %d.\n", WSAGetLastError());
+    ok(bytes_returned == 0, "Got unexpected bytes_returned %u.\n", bytes_returned);
+
+    ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, address_list,
+            FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[0]), &bytes_returned, NULL, NULL);
+    ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
+    ok(WSAGetLastError() == WSAEFAULT, "Got unexpected error %d.\n", WSAGetLastError());
+    ok(bytes_returned == size, "Got unexpected bytes_returned %u, expected %u.\n", bytes_returned, size);
+
     HeapFree(GetProcessHeap(), 0, address_list);
     closesocket(s);
 }




More information about the wine-cvs mailing list