mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
ws2_32: Return WSAEINVAL if "out_size" is smaller than the minimum size for SIO_ADDRESS_LIST_QUERY.
This commit is contained in:
parent
4e6ebd633a
commit
b914a6461b
2 changed files with 19 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue