Commit f0b42b2f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32: Check if the socket is bound in listen() in the server.

parent 43a1a248
......@@ -3282,20 +3282,9 @@ int WINAPI WS_listen( SOCKET s, int backlog )
struct afd_listen_params params = {.backlog = backlog};
IO_STATUS_BLOCK io;
NTSTATUS status;
int fd, bound;
TRACE( "socket %#lx, backlog %d\n", s, backlog );
if ((fd = get_sock_fd( s, FILE_READ_DATA, NULL )) == -1)
return -1;
bound = is_fd_bound( fd, NULL, NULL );
release_sock_fd( s, fd );
if (bound <= 0)
{
SetLastError( bound ? wsaErrno() : WSAEINVAL );
return -1;
}
status = NtDeviceIoControlFile( SOCKET2HANDLE(s), NULL, NULL, NULL, &io,
IOCTL_AFD_LISTEN, &params, sizeof(params), NULL, 0 );
SetLastError( NtStatusToWSAError( status ) );
......
......@@ -2084,6 +2084,12 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return 0;
}
if (!sock->bound)
{
set_error( STATUS_INVALID_PARAMETER );
return 0;
}
if (listen( unix_fd, params->backlog ) < 0)
{
set_error( sock_get_ntstatus( errno ) );
......
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