From: Paul Gofman pgofman@codeweavers.com
--- dlls/ws2_32/socket.c | 6 ++++++ dlls/ws2_32/tests/sock.c | 13 +++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 6a93d00730a..964724b36e7 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3626,6 +3626,12 @@ BOOL WINAPI WSAGetOverlappedResult( SOCKET s, LPWSAOVERLAPPED lpOverlapped, return FALSE; }
+ if (!socket_list_find( s )) + { + SetLastError( WSAENOTSOCK ); + return FALSE; + } + status = lpOverlapped->Internal; if (status == STATUS_PENDING) { diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 4a4a3a84e51..22e414e02ec 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -11848,6 +11848,7 @@ static void test_WSAGetOverlappedResult(void) NTSTATUS status; unsigned int i; SOCKET s; + HANDLE h; BOOL ret;
static const NTSTATUS ranges[][2] = @@ -11862,8 +11863,20 @@ static void test_WSAGetOverlappedResult(void) {0xd0070000, 0xd0080000}, };
+ WSASetLastError(0xdeadbeef); + ret = WSAGetOverlappedResult(0xdeadbeef, &overlapped, &size, FALSE, &flags); + ok(!ret, "got %d.\n", ret); + ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError()); + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ret = DuplicateHandle(GetCurrentProcess(), (HANDLE)s, GetCurrentProcess(), &h, 0, FALSE, DUPLICATE_SAME_ACCESS); + ok(ret, "got %d.\n", ret); + ret = WSAGetOverlappedResult((SOCKET)h, &overlapped, &size, FALSE, &flags); + ok(!ret, "got %d.\n", ret); + ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError()); + CloseHandle(h); + for (i = 0; i < ARRAY_SIZE(ranges); ++i) { for (status = ranges[i][0]; status < ranges[i][1]; ++status)