Commit 3b33a6b4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Explicitly forbid connecting a listening or connected socket.

parent 34e3301b
...@@ -6626,14 +6626,14 @@ static void test_connect(void) ...@@ -6626,14 +6626,14 @@ static void test_connect(void)
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
iret = connect(listener, (struct sockaddr *)&address, sizeof(address)); iret = connect(listener, (struct sockaddr *)&address, sizeof(address));
ok(iret == -1, "got %d\n", iret); ok(iret == -1, "got %d\n", iret);
todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError()); ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
overlapped.Internal = 0xdeadbeef; overlapped.Internal = 0xdeadbeef;
overlapped.InternalHigh = 0xdeadbeef; overlapped.InternalHigh = 0xdeadbeef;
iret = pConnectEx(listener, (struct sockaddr *)&address, sizeof(address), NULL, 0, &bytesReturned, &overlapped); iret = pConnectEx(listener, (struct sockaddr *)&address, sizeof(address), NULL, 0, &bytesReturned, &overlapped);
ok(!iret, "got %d\n", iret); ok(!iret, "got %d\n", iret);
todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError()); ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
ok(overlapped.Internal == STATUS_PENDING, "got status %#x\n", (NTSTATUS)overlapped.Internal); ok(overlapped.Internal == STATUS_PENDING, "got status %#x\n", (NTSTATUS)overlapped.Internal);
todo_wine ok(overlapped.InternalHigh == 0xdeadbeef, "got size %Iu\n", overlapped.InternalHigh); todo_wine ok(overlapped.InternalHigh == 0xdeadbeef, "got size %Iu\n", overlapped.InternalHigh);
...@@ -6706,7 +6706,7 @@ static void test_connect(void) ...@@ -6706,7 +6706,7 @@ static void test_connect(void)
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
iret = connect(connector, (struct sockaddr *)&address, sizeof(address)); iret = connect(connector, (struct sockaddr *)&address, sizeof(address));
todo_wine ok(iret == -1, "got %d\n", iret); ok(iret == -1, "got %d\n", iret);
todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError()); todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
...@@ -6740,8 +6740,8 @@ static void test_connect(void) ...@@ -6740,8 +6740,8 @@ static void test_connect(void)
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
iret = connect(connector, (struct sockaddr *)&address, sizeof(address)); iret = connect(connector, (struct sockaddr *)&address, sizeof(address));
todo_wine ok(iret == -1, "got %d\n", iret); ok(iret == -1, "got %d\n", iret);
todo_wine ok(WSAGetLastError() == WSAEISCONN, "got error %u\n", WSAGetLastError()); ok(WSAGetLastError() == WSAEISCONN, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
iret = connect(acceptor, (struct sockaddr *)&address, sizeof(address)); iret = connect(acceptor, (struct sockaddr *)&address, sizeof(address));
......
...@@ -2164,12 +2164,25 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) ...@@ -2164,12 +2164,25 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return 0; return 0;
} }
if (sock->state == SOCK_CONNECTING) switch (sock->state)
{ {
/* FIXME: STATUS_ADDRESS_ALREADY_ASSOCIATED probably isn't right, case SOCK_LISTENING:
* but there's no status code that maps to WSAEALREADY... */ set_error( STATUS_INVALID_PARAMETER );
set_error( params->synchronous ? STATUS_ADDRESS_ALREADY_ASSOCIATED : STATUS_INVALID_PARAMETER ); return 0;
return 0;
case SOCK_CONNECTING:
/* FIXME: STATUS_ADDRESS_ALREADY_ASSOCIATED probably isn't right,
* but there's no status code that maps to WSAEALREADY... */
set_error( params->synchronous ? STATUS_ADDRESS_ALREADY_ASSOCIATED : STATUS_INVALID_PARAMETER );
return 0;
case SOCK_CONNECTED:
set_error( STATUS_CONNECTION_ACTIVE );
return 0;
case SOCK_UNCONNECTED:
case SOCK_CONNECTIONLESS:
break;
} }
unix_len = sockaddr_to_unix( addr, params->addr_len, &unix_addr ); unix_len = sockaddr_to_unix( addr, params->addr_len, &unix_addr );
......
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