wine-staging/patches/kernel32-MoveFile/0005-kernel32-MoveFile-should-make-sure-that-it-has-the-d.patch
Alistair Leslie-Hughes 39cafb1db1 Updated ML-patchset
Dropped the FILE_FLAG_WRITE_THROUGH patches since they appear to be breaking multiple applications.
Bug 45599, 45604.
2018-08-10 20:17:50 +10:00

77 lines
3.4 KiB
Diff

From 96e7b57c5591087cfd07b0658ac33a1ec6bde3b5 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 15 Nov 2016 13:32:42 +0800
Subject: kernel32: MoveFile should make sure that it has the delete access to
the source file.
---
dlls/kernel32/path.c | 6 ++++--
dlls/kernel32/tests/file.c | 20 ++++++++------------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index f554d14..d7fc20e 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1338,7 +1338,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
- status = NtOpenFile( &source_handle, SYNCHRONIZE, &attr, &io, 0, FILE_SYNCHRONOUS_IO_NONALERT );
+ status = NtOpenFile( &source_handle, DELETE | SYNCHRONIZE, &attr, &io,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_SYNCHRONOUS_IO_NONALERT );
if (status == STATUS_SUCCESS)
status = wine_nt_to_unix_file_name( &nt_name, &source_unix, FILE_OPEN, FALSE );
RtlFreeUnicodeString( &nt_name );
@@ -1362,7 +1363,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
SetLastError( ERROR_PATH_NOT_FOUND );
goto error;
}
- status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &io, 0,
+ status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &io,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
if (status == STATUS_SUCCESS) /* destination exists */
{
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index f0f9232..6fcf019 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -1905,12 +1905,10 @@ static void test_MoveFileA(void)
ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
ret = MoveFileA(source, dest);
- todo_wine {
- ok(!ret, "MoveFileA: expected failure\n");
- ok(GetLastError() == ERROR_SHARING_VIOLATION ||
- broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
- "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
- }
+ ok(!ret, "MoveFileA: expected failure\n");
+ ok(GetLastError() == ERROR_SHARING_VIOLATION ||
+ broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
+ "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
CloseHandle(hmapfile);
CloseHandle(hfile);
@@ -1925,12 +1923,10 @@ static void test_MoveFileA(void)
ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
ret = MoveFileA(source, dest);
- todo_wine {
- ok(!ret, "MoveFileA: expected failure\n");
- ok(GetLastError() == ERROR_SHARING_VIOLATION ||
- broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
- "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
- }
+ ok(!ret, "MoveFileA: expected failure\n");
+ ok(GetLastError() == ERROR_SHARING_VIOLATION ||
+ broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
+ "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
CloseHandle(hmapfile);
CloseHandle(hfile);
--
2.9.0