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

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-06-16 23:33:09 -05:00 committed by Alexandre Julliard
parent 43a1a248c3
commit f0b42b2ffa
2 changed files with 6 additions and 11 deletions

View File

@ -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 ) );

View File

@ -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 ) );