ws2_32: Always return WSAEFAULT from WSAIoctl() if ret_size is NULL.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fde6cd46c8
commit
e3e17ba7f8
|
@ -3329,7 +3329,7 @@ static DWORD get_interface_list(SOCKET s, void *out_buff, DWORD out_size, DWORD
|
|||
DWORD status = 0;
|
||||
int fd;
|
||||
|
||||
if (!out_buff || !ret_size)
|
||||
if (!out_buff)
|
||||
return WSAEFAULT;
|
||||
|
||||
if ((fd = get_sock_fd(s, 0, NULL)) == -1)
|
||||
|
@ -3451,6 +3451,12 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
|
|||
TRACE("%04lx, %s, %p, %d, %p, %d, %p, %p, %p\n",
|
||||
s, debugstr_wsaioctl(code), in_buff, in_size, out_buff, out_size, ret_size, overlapped, completion);
|
||||
|
||||
if (!ret_size)
|
||||
{
|
||||
SetLastError( WSAEFAULT );
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case WS_FIONBIO:
|
||||
|
@ -3544,12 +3550,6 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
|
|||
|
||||
TRACE("-> SIO_ADDRESS_LIST_QUERY request\n");
|
||||
|
||||
if (!ret_size)
|
||||
{
|
||||
SetLastError(WSAEFAULT);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
if (out_size && out_size < FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[0]))
|
||||
{
|
||||
*ret_size = 0;
|
||||
|
@ -3718,7 +3718,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
|
|||
TRACE("-> WS_SIO_ROUTING_INTERFACE_QUERY request\n");
|
||||
|
||||
if (!in_buff || in_size < sizeof(struct WS_sockaddr) ||
|
||||
!out_buff || out_size < sizeof(struct WS_sockaddr_in) || !ret_size)
|
||||
!out_buff || out_size < sizeof(struct WS_sockaddr_in))
|
||||
{
|
||||
SetLastError(WSAEFAULT);
|
||||
return SOCKET_ERROR;
|
||||
|
@ -3816,7 +3816,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
|
|||
|
||||
if (!status)
|
||||
{
|
||||
if (ret_size) *ret_size = total;
|
||||
*ret_size = total;
|
||||
return 0;
|
||||
}
|
||||
SetLastError( status );
|
||||
|
|
|
@ -3705,8 +3705,8 @@ static void test_fionread_siocatmark(void)
|
|||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
ret = WSAIoctl(client, FIONREAD, NULL, 0, &value, sizeof(value), NULL, NULL, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -3717,8 +3717,8 @@ static void test_fionread_siocatmark(void)
|
|||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
ret = WSAIoctl(client, SIOCATMARK, NULL, 0, &value, sizeof(value), NULL, NULL, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -3732,12 +3732,12 @@ static void test_fionread_siocatmark(void)
|
|||
port = CreateIoCompletionPort((HANDLE)client, NULL, 123, 0);
|
||||
|
||||
ret = WSAIoctl(client, FIONREAD, NULL, 0, &value, sizeof(value), NULL, &overlapped, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
ret = WSAIoctl(client, SIOCATMARK, NULL, 0, &value, sizeof(value), NULL, &overlapped, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -3857,12 +3857,12 @@ static void test_fionread_siocatmark(void)
|
|||
server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
ret = WSAIoctl(server, FIONREAD, NULL, 0, &value, sizeof(value), NULL, &overlapped, socket_apc);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
ret = WSAIoctl(server, SIOCATMARK, NULL, 0, &value, sizeof(value), NULL, &overlapped, socket_apc);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
apc_count = 0;
|
||||
size = 0xdeadbeef;
|
||||
|
@ -3920,8 +3920,8 @@ static void test_fionbio(void)
|
|||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one), NULL, 0, NULL, NULL, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one) - 1, NULL, 0, &size, &overlapped, NULL);
|
||||
ok(ret == -1, "expected failure\n");
|
||||
|
@ -3952,7 +3952,7 @@ static void test_fionbio(void)
|
|||
ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
|
||||
|
||||
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one), NULL, 0, NULL, &overlapped, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
ret = WSAEventSelect(s, event, FD_READ);
|
||||
|
@ -3974,8 +3974,8 @@ static void test_fionbio(void)
|
|||
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
ret = WSAIoctl(s, FIONBIO, &one, sizeof(one), NULL, 0, NULL, &overlapped, socket_apc);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
apc_count = 0;
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4033,12 +4033,12 @@ static void test_keepalive_vals(void)
|
|||
ok(!size, "got size %u\n", size);
|
||||
|
||||
ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(kalive), NULL, 0, NULL, NULL, NULL);
|
||||
todo_wine ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(kalive), NULL, 0, NULL, &overlapped, NULL);
|
||||
todo_wine ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4093,8 +4093,8 @@ static void test_keepalive_vals(void)
|
|||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(kalive), NULL, 0, NULL, &overlapped, socket_apc);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
apc_count = 0;
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4135,9 +4135,8 @@ static void test_unsupported_ioctls(void)
|
|||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
ret = WSAIoctl(s, codes[i], NULL, 0, NULL, 0, NULL, &overlapped, NULL);
|
||||
todo_wine_if (codes[i] == SIO_FLUSH)
|
||||
ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4182,9 +4181,8 @@ static void test_unsupported_ioctls(void)
|
|||
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
ret = WSAIoctl(s, codes[i], NULL, 0, NULL, 0, NULL, &overlapped, socket_apc);
|
||||
todo_wine_if (codes[i] == SIO_FLUSH)
|
||||
ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
apc_count = 0;
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4228,8 +4226,8 @@ static void test_get_extension_func(void)
|
|||
WSASetLastError(0xdeadbeef);
|
||||
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
|
||||
&func, sizeof(func), NULL, &overlapped, NULL);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
WSASetLastError(0xdeadbeef);
|
||||
size = 0xdeadbeef;
|
||||
|
@ -4269,7 +4267,7 @@ static void test_get_extension_func(void)
|
|||
todo_wine ok(overlapped.InternalHigh == 0xdeadbeef, "got size %Iu\n", overlapped.InternalHigh);
|
||||
|
||||
ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped_ptr, 0);
|
||||
todo_wine ok(!ret, "expected failure\n");
|
||||
ok(!ret, "expected failure\n");
|
||||
todo_wine ok(GetLastError() == WAIT_TIMEOUT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
CloseHandle(port);
|
||||
|
@ -4279,8 +4277,8 @@ static void test_get_extension_func(void)
|
|||
|
||||
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
|
||||
&func, sizeof(func), NULL, &overlapped, socket_apc);
|
||||
todo_wine ok(ret == -1, "expected failure\n");
|
||||
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
ok(ret == -1, "expected failure\n");
|
||||
ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
|
||||
|
||||
apc_count = 0;
|
||||
size = 0xdeadbeef;
|
||||
|
|
Loading…
Reference in New Issue