From c73316db5b93840197f3eb5a5ddb51ad5fbcfadb Mon Sep 17 00:00:00 2001
From: Eric Pouech <eric.pouech@wanadoo.fr>
Date: Mon, 8 Oct 2001 20:57:12 +0000
Subject: [PATCH] - fixed copy&paste bug (GENERIC_WRITE instead of
 GENERIC_READ) - when getting the type of a handle, it has to be done even if
 no fd   is attached to it (console for example)

---
 files/file.c  | 4 ++--
 server/file.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/files/file.c b/files/file.c
index 4ec9a405ca5..05166e3b9b2 100644
--- a/files/file.c
+++ b/files/file.c
@@ -219,8 +219,8 @@ int FILE_GetUnixHandleType( HANDLE handle, DWORD access, DWORD *type )
             if (!(ret = SERVER_CALL_ERR()))
             {
                 fd = req->fd;
-                if (type) *type = req->type;
             }
+	    if (type) *type = req->type;
         }
         SERVER_END_REQ;
         if (ret) return -1;
@@ -1378,7 +1378,7 @@ static BOOL FILE_ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
         return FALSE;
     }
 
-    fd = FILE_GetUnixHandle( hFile, GENERIC_WRITE );
+    fd = FILE_GetUnixHandle( hFile, GENERIC_READ );
     if(fd<0)
     {
         TRACE("Couldn't get FD\n");
diff --git a/server/file.c b/server/file.c
index c79efa68bd6..a9725766cf7 100644
--- a/server/file.c
+++ b/server/file.c
@@ -495,6 +495,7 @@ DECL_HANDLER(get_handle_fd)
     struct object *obj;
 
     req->fd = -1;
+    req->type = FD_TYPE_INVALID;
     if ((obj = get_handle_obj( current->process, req->handle, req->access, NULL )))
     {
         int fd = get_handle_fd( current->process, req->handle, req->access );
-- 
GitLab