[PATCH 3/3] server: Forbid accepting into the same socket more than once.
Zebediah Figura
z.figura12 at gmail.com
Fri Oct 16 23:13:37 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/ws2_32/tests/sock.c | 16 +---------------
server/sock.c | 7 +++++++
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index c20a83b4261..832f2bf928e 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7551,23 +7551,9 @@ todo_wine
bret = pAcceptEx(listener, acceptor, buffer, 0,
sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16,
&bytesReturned, &overlapped);
- todo_wine ok(bret == FALSE && WSAGetLastError() == WSAEINVAL,
+ ok(bret == FALSE && WSAGetLastError() == WSAEINVAL,
"AcceptEx on already pending socket returned %d + errno %d\n", bret, WSAGetLastError());
ok(overlapped.Internal == STATUS_PENDING, "got %08x\n", (ULONG)overlapped.Internal);
- if (bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING) {
- /* We need to cancel this call, otherwise things fail */
- bret = CancelIo((HANDLE) listener);
- ok(bret, "Failed to cancel failed test. Bailing...\n");
- if (!bret) return;
- WaitForSingleObject(overlapped.hEvent, 0);
-
- overlapped.Internal = 0xdeadbeef;
- bret = pAcceptEx(listener, acceptor, buffer, 0,
- sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16,
- &bytesReturned, &overlapped);
- ok(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING, "AcceptEx returned %d + errno %d\n", bret, WSAGetLastError());
- ok(overlapped.Internal == STATUS_PENDING, "got %08x\n", (ULONG)overlapped.Internal);
- }
iret = connect(acceptor, (struct sockaddr*)&bindAddress, sizeof(bindAddress));
todo_wine ok(iret == SOCKET_ERROR && WSAGetLastError() == WSAEINVAL,
diff --git a/server/sock.c b/server/sock.c
index 2ef16ed3246..9e6f44a110c 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -1458,6 +1458,13 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
if (!(acceptsock = (struct sock *)get_handle_obj( current->process, params->accept_handle, access, &sock_ops )))
return 0;
+ if (acceptsock->accept_recv_req)
+ {
+ release_object( acceptsock );
+ set_win32_error( WSAEINVAL );
+ return 0;
+ }
+
if (!(req = alloc_accept_req( acceptsock, async, params ))) return 0;
list_add_tail( &sock->accept_list, &req->entry );
acceptsock->accept_recv_req = req;
--
2.28.0
More information about the wine-devel
mailing list