Jacek Caban : server: Properly handle disconnected pipe in set_named_pipe_info request.

Alexandre Julliard julliard at winehq.org
Fri Nov 23 14:18:03 CST 2018


Module: wine
Branch: master
Commit: 29be73765255c4b9386eb5561adf8f5b3434dc7e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=29be73765255c4b9386eb5561adf8f5b3434dc7e

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Nov 23 15:12:35 2018 +0100

server: Properly handle disconnected pipe in set_named_pipe_info request.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/pipe.c | 15 ++++++++++++++-
 server/named_pipe.c     |  6 +++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c
index 406d555..8448bab 100644
--- a/dlls/ntdll/tests/pipe.c
+++ b/dlls/ntdll/tests/pipe.c
@@ -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)
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 19a5426..b96af7b 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -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 );




More information about the wine-cvs mailing list