2018-08-02 17:08:24 -07:00
|
|
|
From 6e5c9277d35def4b312820f11ef8a7586f788124 Mon Sep 17 00:00:00 2001
|
2016-11-15 11:27:21 -08:00
|
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
|
|
Date: Tue, 15 Nov 2016 13:32:42 +0800
|
2018-08-02 17:08:24 -07:00
|
|
|
Subject: [PATCH] kernel32: MoveFile should make sure that it has the delete
|
|
|
|
access to the source file.
|
2016-11-15 11:27:21 -08:00
|
|
|
|
|
|
|
---
|
|
|
|
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
|
2018-08-02 17:08:24 -07:00
|
|
|
index c7c5cbd..855330b 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/dlls/kernel32/path.c
|
|
|
|
+++ b/dlls/kernel32/path.c
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1383,7 +1383,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
|
2016-11-15 11:27:21 -08:00
|
|
|
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 );
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1411,7 +1412,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
|
|
|
|
options = FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT;
|
|
|
|
if (flag & MOVEFILE_WRITE_THROUGH)
|
|
|
|
options |= FILE_WRITE_THROUGH;
|
|
|
|
- status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &io, 0, options );
|
|
|
|
+ status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &io,
|
|
|
|
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, options );
|
2016-11-15 11:27:21 -08:00
|
|
|
if (status == STATUS_SUCCESS) /* destination exists */
|
|
|
|
{
|
2018-08-02 17:08:24 -07:00
|
|
|
if (!(flag & MOVEFILE_REPLACE_EXISTING))
|
2016-11-15 11:27:21 -08:00
|
|
|
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
2018-08-02 17:08:24 -07:00
|
|
|
index 07b3ffb..4729e75 100644
|
2016-11-15 11:27:21 -08:00
|
|
|
--- a/dlls/kernel32/tests/file.c
|
|
|
|
+++ b/dlls/kernel32/tests/file.c
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1906,12 +1906,10 @@ static void test_MoveFileA(void)
|
2016-11-15 11:27:21 -08:00
|
|
|
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);
|
2018-08-02 17:08:24 -07:00
|
|
|
@@ -1926,12 +1924,10 @@ static void test_MoveFileA(void)
|
2016-11-15 11:27:21 -08:00
|
|
|
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);
|
|
|
|
--
|
2018-08-02 17:08:24 -07:00
|
|
|
1.9.1
|
2016-11-15 11:27:21 -08:00
|
|
|
|