From 8031fda3ffc4d2469524f21198ef0aaf9725562e Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 15 Nov 2016 13:32:42 +0800 Subject: [PATCH] kernel32: MoveFile should make sure that it has the delete access to the source file. --- dlls/kernel32/path.c | 4 ++-- dlls/kernel32/tests/file.c | 20 ++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index c7c5cbd3f7..5388586094 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1383,7 +1383,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 ); @@ -1407,7 +1408,6 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, SetLastError( ERROR_PATH_NOT_FOUND ); goto error; } - options = FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT; if (flag & MOVEFILE_WRITE_THROUGH) options |= FILE_WRITE_THROUGH; diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 07b3ffb77b..4729e75728 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1906,12 +1906,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); @@ -1926,12 +1924,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.18.0