Commit d0009573 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

ws2_32: Fix some parameters checking in AcceptEx.

parent cba19b90
......@@ -2319,6 +2319,13 @@ static BOOL WINAPI WS2_AcceptEx(SOCKET listener, SOCKET acceptor, PVOID dest, DW
return FALSE;
}
if ((local_addr_len < sizeof(struct sockaddr_in) + 16)
|| (rem_addr_len < sizeof(struct sockaddr_in) + 16))
{
SetLastError(WSAEINVAL);
return FALSE;
}
fd = get_sock_fd( listener, FILE_READ_DATA, NULL );
if (fd == -1)
{
......
......@@ -5348,12 +5348,22 @@ static void test_AcceptEx(void)
bret = pAcceptEx(listener, acceptor, buffer, 0, 0, sizeof(struct sockaddr_in) + 16,
&bytesReturned, &overlapped);
todo_wine ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small local address size "
ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small local address size "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 15,
sizeof(struct sockaddr_in) + 16, &bytesReturned, &overlapped);
ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small local address size "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 16, 0,
&bytesReturned, &overlapped);
todo_wine ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small remote address size "
ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small remote address size "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 16,
sizeof(struct sockaddr_in) + 15, &bytesReturned, &overlapped);
ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on too small remote address size "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, 0,
......@@ -5362,6 +5372,10 @@ static void test_AcceptEx(void)
ok(bret == FALSE && WSAGetLastError() == ERROR_INVALID_PARAMETER, "AcceptEx on a NULL overlapped "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, 0, 0, 0, &bytesReturned, NULL);
ok(bret == FALSE && WSAGetLastError() == ERROR_INVALID_PARAMETER, "AcceptEx on a NULL overlapped "
"returned %d + errno %d\n", bret, WSAGetLastError());
bret = pAcceptEx(listener, acceptor, buffer, sizeof(buffer) - 2*(sizeof(struct sockaddr_in) + 16),
sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16,
&bytesReturned, &overlapped);
......
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