Commit 4e6ebd63 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ws2_32: Return the needed buffer size for SIO_ADDRESS_LIST_QUERY.

parent 2bcbbea5
......@@ -3957,6 +3957,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
if (total > out_size)
{
*ret_size = total;
HeapFree(GetProcessHeap(), 0, table);
status = WSAEFAULT;
break;
......
......@@ -7462,6 +7462,46 @@ static void test_completion_port(void)
CloseHandle(previous_port);
}
static void test_address_list_query(void)
{
SOCKET_ADDRESS_LIST *address_list;
DWORD bytes_returned, size;
unsigned int i;
SOCKET s;
int ret;
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
ok(s != INVALID_SOCKET, "Failed to create socket, error %d.\n", WSAGetLastError());
bytes_returned = 0;
ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, NULL, 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 >= FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[0]),
"Got unexpected bytes_returned %u.\n", bytes_returned);
size = bytes_returned;
bytes_returned = 0;
address_list = HeapAlloc(GetProcessHeap(), 0, size * 2);
ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, address_list, size * 2, &bytes_returned, NULL, NULL);
ok(!ret, "Got unexpected ret %d, error %d.\n", ret, WSAGetLastError());
ok(bytes_returned == size, "Got unexpected bytes_returned %u, expected %u.\n", bytes_returned, size);
bytes_returned = FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[address_list->iAddressCount]);
for (i = 0; i < address_list->iAddressCount; ++i)
{
bytes_returned += address_list->Address[i].iSockaddrLength;
}
ok(size == bytes_returned, "Got unexpected size %u, expected %u.\n", size, bytes_returned);
ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, address_list, size, NULL, NULL, NULL);
ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret);
ok(WSAGetLastError() == WSAEFAULT, "Got unexpected error %d.\n", WSAGetLastError());
HeapFree(GetProcessHeap(), 0, address_list);
closesocket(s);
}
static DWORD WINAPI inet_ntoa_thread_proc(void *param)
{
ULONG addr;
......@@ -7739,6 +7779,7 @@ START_TEST( sock )
test_WSAAsyncGetServByName();
test_completion_port();
test_address_list_query();
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
test_send();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment