Jacek Caban : server: Don' t allow APCs on objects associated with completion port.
Alexandre Julliard
julliard at winehq.org
Mon Jul 10 15:52:47 CDT 2017
Module: wine
Branch: master
Commit: 82e6713b75d223ee1ac68812a394626aa2884c21
URL: http://source.winehq.org/git/wine.git/?a=commit;h=82e6713b75d223ee1ac68812a394626aa2884c21
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Jul 10 12:51:05 2017 +0200
server: Don't allow APCs on objects associated with completion port.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/file.c | 2 --
dlls/ws2_32/tests/sock.c | 1 -
server/async.c | 11 +++++++++--
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 71b37e4..ff27d98 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1045,7 +1045,6 @@ static void test_iocp_fileio(HANDLE h)
/* using APCs on handle with associated completion port is not allowed */
res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL );
- todo_wine
ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res);
}
@@ -1094,7 +1093,6 @@ static void test_iocp_fileio(HANDLE h)
/* using APCs on handle with associated completion port is not allowed */
res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL );
- todo_wine
ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res);
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 2790fea..efe10b3 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -6824,7 +6824,6 @@ static void test_WSARecv(void)
memset(&ov, 0, sizeof(ov));
completion_called = 0;
iret = WSARecv(dest, bufs, 1, NULL, &flags, &ov, io_completion);
- todo_wine
ok(iret == SOCKET_ERROR && GetLastError() == WSAEINVAL, "WSARecv failed - %d error %d\n", iret, GetLastError());
ok(!completion_called, "completion called\n");
diff --git a/server/async.c b/server/async.c
index 0205807..1cb020f 100644
--- a/server/async.c
+++ b/server/async.c
@@ -192,7 +192,7 @@ void free_async_queue( struct async_queue *queue )
LIST_FOR_EACH_ENTRY_SAFE( async, next, &queue->queue, struct async, queue_entry )
{
- async->completion = fd_get_completion( async->fd, &async->comp_key );
+ if (!async->completion) async->completion = fd_get_completion( async->fd, &async->comp_key );
async->fd = NULL;
async_terminate( async, STATUS_HANDLES_CLOSED );
async->queue = NULL;
@@ -236,7 +236,7 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da
async->signaled = 0;
async->wait_handle = 0;
async->direct_result = 0;
- async->completion = NULL;
+ async->completion = fd_get_completion( fd, &async->comp_key );
if (iosb) async->iosb = (struct iosb *)grab_object( iosb );
else async->iosb = NULL;
@@ -244,6 +244,13 @@ struct async *create_async( struct fd *fd, struct thread *thread, const async_da
list_add_head( &thread->process->asyncs, &async->process_entry );
if (event) reset_event( event );
+ if (async->completion && data->apc)
+ {
+ release_object( async );
+ set_error( STATUS_INVALID_PARAMETER );
+ return NULL;
+ }
+
return async;
}
More information about the wine-cvs
mailing list