server: Fix crash when calling GetNamedPipeHandleState on partially closed pipe.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2015-11-23 07:23:45 +01:00 committed by Alexandre Julliard
parent 78948b24b7
commit ee02530bc4
2 changed files with 21 additions and 6 deletions

View File

@ -1387,9 +1387,9 @@ static void test_CreatePipe(void)
static void test_CloseHandle(void)
{
static const char testdata[] = "Hello World";
DWORD state, numbytes;
HANDLE hpipe, hfile;
char buffer[32];
DWORD numbytes;
BOOL ret;
hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
@ -1425,6 +1425,9 @@ static void test_CloseHandle(void)
ok(ret, "ReadFile failed with %u\n", GetLastError());
ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
ok(!ret, "ReadFile unexpectedly succeeded\n");
@ -1459,6 +1462,9 @@ static void test_CloseHandle(void)
todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError());
ok(numbytes == 0, "expected 0, got %u\n", numbytes);
ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
ok(!ret, "ReadFile unexpectedly succeeded\n");
@ -1507,6 +1513,9 @@ static void test_CloseHandle(void)
ok(ret, "ReadFile failed with %u\n", GetLastError());
ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
ok(!ret, "ReadFile unexpectedly succeeded\n");
@ -1541,6 +1550,9 @@ static void test_CloseHandle(void)
todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError());
ok(numbytes == 0, "expected 0, got %u\n", numbytes);
ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
ok(!ret, "ReadFile unexpectedly succeeded\n");

View File

@ -1013,11 +1013,14 @@ DECL_HANDLER(get_named_pipe_info)
}
reply->flags = client ? client->pipe_flags : server->pipe_flags;
if (server)
{
reply->sharing = server->pipe->sharing;
reply->maxinstances = server->pipe->maxinstances;
reply->instances = server->pipe->instances;
reply->insize = server->pipe->insize;
reply->outsize = server->pipe->outsize;
}
if (client)
release_object(client);