Commit f9d40575 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

ws2_32: Accept shouldn't fail when addrlen32 is NULL.

parent 18420826
......@@ -2653,7 +2653,7 @@ SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr, int *addrlen32)
SERVER_END_REQ;
if (!status)
{
if (addr && WS_getpeername(as, addr, addrlen32))
if (addr && addrlen32 && WS_getpeername(as, addr, addrlen32))
{
WS_closesocket(as);
return SOCKET_ERROR;
......
......@@ -4068,7 +4068,7 @@ static void test_accept(void)
int ret;
SOCKET server_socket, accepted = INVALID_SOCKET, connector;
struct sockaddr_in address;
SOCKADDR_STORAGE ss;
SOCKADDR_STORAGE ss, ss_empty;
int socklen;
select_thread_params thread_params;
HANDLE thread_handle = NULL;
......@@ -4199,6 +4199,19 @@ static void test_accept(void)
ok(accepted != INVALID_SOCKET, "Failed to accept connection, %d\n", WSAGetLastError());
ok(socklen != sizeof(ss), "unexpected length\n");
ok(ss.ss_family, "family not set\n");
closesocket(accepted);
closesocket(connector);
accepted = connector = INVALID_SOCKET;
socklen = sizeof(address);
connector = setup_connector_socket(&address, socklen, FALSE);
if (connector == INVALID_SOCKET) goto done;
memset(&ss, 0, sizeof(ss));
memset(&ss_empty, 0, sizeof(ss_empty));
accepted = accept(server_socket, (struct sockaddr *)&ss, NULL);
ok(accepted != INVALID_SOCKET, "Failed to accept connection, %d\n", WSAGetLastError());
ok(!memcmp(&ss, &ss_empty, sizeof(ss)), "structure is different\n");
done:
if (accepted != INVALID_SOCKET)
......
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