[PATCH 2/5] ws2_32: Check if the socket is bound in listen() in the server.
Zebediah Figura
z.figura12 at gmail.com
Wed Jun 16 23:33:09 CDT 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/ws2_32/socket.c | 11 -----------
server/sock.c | 6 ++++++
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 63c26a9c769..c8403808d8f 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -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, ¶ms, sizeof(params), NULL, 0 );
SetLastError( NtStatusToWSAError( status ) );
diff --git a/server/sock.c b/server/sock.c
index 23c750243a6..39575b22f76 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -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 ) );
--
2.30.2
More information about the wine-devel
mailing list