server: Properly handle disconnected pipe in set_named_pipe_info request.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Jacek Caban 2018-11-23 15:12:35 +01:00 committed by Alexandre Julliard
parent 5c23f33588
commit 29be737652
2 changed files with 19 additions and 2 deletions

View File

@ -2042,7 +2042,7 @@ static HANDLE connect_pipe_reader(HANDLE server)
{
HANDLE client;
client = CreateFileW(testpipe, GENERIC_READ, 0, 0, OPEN_EXISTING,
client = CreateFileW(testpipe, GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, 0);
ok(client != INVALID_HANDLE_VALUE, "can't open pipe: %u\n", GetLastError());
@ -2146,6 +2146,19 @@ static void test_pipe_local_info(HANDLE pipe, BOOL is_server, DWORD state)
ok(pipe_info.ReadMode == 0, "ReadMode = %u\n", pipe_info.ReadMode);
ok(pipe_info.CompletionMode == 0, "CompletionMode = %u\n", pipe_info.CompletionMode);
}
pipe_info.ReadMode = 0;
pipe_info.CompletionMode = 0;
memset(&iosb, 0xcc, sizeof(iosb));
status = pNtSetInformationFile(pipe, &iosb, &pipe_info, sizeof(pipe_info), FilePipeInformation);
if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
ok(status == STATUS_PIPE_DISCONNECTED,
"NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n",
is_server ? "server" : "client", state, status);
else
ok(status == STATUS_SUCCESS,
"NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n",
is_server ? "server" : "client", state, status);
}
static void test_file_info(void)

View File

@ -1427,7 +1427,11 @@ DECL_HANDLER(set_named_pipe_info)
if (!pipe_end) return;
}
if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) ||
if (!pipe_end->pipe)
{
set_error( STATUS_PIPE_DISCONNECTED );
}
else if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) ||
((req->flags & NAMED_PIPE_MESSAGE_STREAM_READ) && !(pipe_end->pipe->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE)))
{
set_error( STATUS_INVALID_PARAMETER );