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

Alexandre Julliard julliard at winehq.org
Thu Jun 17 15:38:05 CDT 2021


Module: wine
Branch: master
Commit: f0b42b2ffa4a0eafedce69211b5d2259163a29dc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f0b42b2ffa4a0eafedce69211b5d2259163a29dc

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Jun 16 23:33:09 2021 -0500

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

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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, &params, 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 ) );




More information about the wine-cvs mailing list