Jacek Caban : kernel32: Always create file with FILE_READ_ATTRIBUTES access in CreateFile.
Alexandre Julliard
julliard at winehq.org
Tue Aug 21 16:49:02 CDT 2018
Module: wine
Branch: master
Commit: 58233b47e0117db1f4767ee5d54ba169976905b2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=58233b47e0117db1f4767ee5d54ba169976905b2
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Aug 20 19:29:46 2018 +0200
kernel32: Always create file with FILE_READ_ATTRIBUTES access in CreateFile.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/advapi32/tests/security.c | 4 ----
dlls/kernel32/file.c | 4 ++--
dlls/kernel32/tests/pipe.c | 5 +++++
dlls/ntdll/tests/pipe.c | 42 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 925e6fa..aebf3b8 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -5620,7 +5620,6 @@ static void test_file_security(HANDLE token)
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
access = get_obj_access(file);
-todo_wine
ok(access == (FILE_READ_ATTRIBUTES | SYNCHRONIZE), "expected FILE_READ_ATTRIBUTES | SYNCHRONIZE, got %#x\n", access);
bytes = 0xdeadbeef;
@@ -5637,7 +5636,6 @@ todo_wine
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
access = get_obj_access(file);
-todo_wine
ok(access == (FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES), "expected FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES, got %#x\n", access);
bytes = 0xdeadbeef;
@@ -5678,7 +5676,6 @@ todo_wine
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
access = get_obj_access(file);
-todo_wine
ok(access == (FILE_READ_ATTRIBUTES | SYNCHRONIZE), "expected FILE_READ_ATTRIBUTES | SYNCHRONIZE, got %#x\n", access);
CloseHandle(file);
@@ -5688,7 +5685,6 @@ todo_wine
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
access = get_obj_access(file);
-todo_wine
ok(access == (FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES), "expected FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES, got %#x\n", access);
CloseHandle(file);
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index b558f8e..081f076 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -1582,8 +1582,8 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
if (sa && sa->bInheritHandle) attr.Attributes |= OBJ_INHERIT;
- status = NtCreateFile( &ret, access | SYNCHRONIZE, &attr, &io, NULL, attributes,
- sharing, nt_disposition[creation - CREATE_NEW],
+ status = NtCreateFile( &ret, access | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attr, &io,
+ NULL, attributes, sharing, nt_disposition[creation - CREATE_NEW],
options, NULL, 0 );
if (status)
{
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 1e67f70..10c971b 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -666,6 +666,11 @@ static void test_CreateNamedPipe(int pipemode)
test_file_access(hnp, SYNCHRONIZE | READ_CONTROL | FILE_WRITE_ATTRIBUTES
| FILE_WRITE_PROPERTIES | FILE_APPEND_DATA | FILE_WRITE_DATA);
+ hFile = CreateFileA(PIPENAME, 0, 0, NULL, OPEN_EXISTING, 0, 0);
+ ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+ test_file_access(hFile, SYNCHRONIZE | FILE_READ_ATTRIBUTES);
+ CloseHandle(hFile);
+
CloseHandle(hnp);
if (winetest_debug > 1) trace("test_CreateNamedPipe returning\n");
diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c
index d6a0d41..1d77d88 100644
--- a/dlls/ntdll/tests/pipe.c
+++ b/dlls/ntdll/tests/pipe.c
@@ -113,6 +113,20 @@ static inline BOOL is_signaled( HANDLE obj )
return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0;
}
+#define test_file_access(a,b) _test_file_access(__LINE__,a,b)
+static void _test_file_access(unsigned line, HANDLE handle, DWORD expected_access)
+{
+ FILE_ACCESS_INFORMATION info;
+ IO_STATUS_BLOCK io;
+ NTSTATUS status;
+
+ memset(&info, 0x11, sizeof(info));
+ status = NtQueryInformationFile(handle, &io, &info, sizeof(info), FileAccessInformation);
+ ok_(__FILE__,line)(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
+ ok_(__FILE__,line)(info.AccessFlags == expected_access, "got access %08x expected %08x\n",
+ info.AccessFlags, expected_access);
+}
+
static const WCHAR testpipe[] = { '\\', '\\', '.', '\\', 'p', 'i', 'p', 'e', '\\',
't', 'e', 's', 't', 'p', 'i', 'p', 'e', 0 };
static const WCHAR testpipe_nt[] = { '\\', '?', '?', '\\', 'p', 'i', 'p', 'e', '\\',
@@ -562,6 +576,7 @@ static void _check_pipe_handle_state(int line, HANDLE handle, ULONG read, ULONG
static void test_filepipeinfo(void)
{
+ FILE_PIPE_LOCAL_INFORMATION local_info;
IO_STATUS_BLOCK iosb;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING name;
@@ -726,6 +741,33 @@ static void test_filepipeinfo(void)
check_pipe_handle_state(hServer, 1, 0);
CloseHandle(hServer);
+
+ res = pNtCreateNamedPipeFile(&hServer,
+ FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
+ &attr, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_CREATE,
+ 0, 1, 1, 0, 0xFFFFFFFF, 500, 500, &timeout);
+ ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
+
+ res = NtCreateFile(&hClient, SYNCHRONIZE, &attr, &iosb, NULL, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, NULL, 0 );
+ ok(!res, "NtCreateFile returned %x\n", res);
+
+ test_file_access(hClient, SYNCHRONIZE);
+
+ res = pNtQueryInformationFile(hClient, &iosb, &local_info, sizeof(local_info),
+ FilePipeLocalInformation);
+ todo_wine
+ ok(res == STATUS_ACCESS_DENIED,
+ "NtQueryInformationFile(FilePipeLocalInformation) returned: %x\n", res);
+
+ res = pNtQueryInformationFile(hClient, &iosb, &local_info, sizeof(local_info),
+ FilePipeInformation);
+ todo_wine
+ ok(res == STATUS_ACCESS_DENIED,
+ "NtQueryInformationFile(FilePipeInformation) returned: %x\n", res);
+
+ CloseHandle(hClient);
+ CloseHandle(hServer);
}
static void WINAPI apc( void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved )
More information about the wine-cvs
mailing list