Commit f184a396 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32: MoveFile should make sure that it has the delete access to the source file.

parent 7edfcd63
...@@ -1310,7 +1310,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, ...@@ -1310,7 +1310,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = 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) if (status == STATUS_SUCCESS)
status = wine_nt_to_unix_file_name( &nt_name, &source_unix, FILE_OPEN, FALSE ); status = wine_nt_to_unix_file_name( &nt_name, &source_unix, FILE_OPEN, FALSE );
RtlFreeUnicodeString( &nt_name ); RtlFreeUnicodeString( &nt_name );
...@@ -1334,11 +1335,11 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, ...@@ -1334,11 +1335,11 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
SetLastError( ERROR_PATH_NOT_FOUND ); SetLastError( ERROR_PATH_NOT_FOUND );
goto error; goto error;
} }
options = FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT; options = FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT;
if (flag & MOVEFILE_WRITE_THROUGH) if (flag & MOVEFILE_WRITE_THROUGH)
options |= FILE_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 );
if (status == STATUS_SUCCESS) /* destination exists */ if (status == STATUS_SUCCESS) /* destination exists */
{ {
if (!(flag & MOVEFILE_REPLACE_EXISTING)) if (!(flag & MOVEFILE_REPLACE_EXISTING))
......
...@@ -1914,12 +1914,10 @@ static void test_MoveFileA(void) ...@@ -1914,12 +1914,10 @@ static void test_MoveFileA(void)
ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError()); ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
ret = MoveFileA(source, dest); ret = MoveFileA(source, dest);
todo_wine { ok(!ret, "MoveFileA: expected failure\n");
ok(!ret, "MoveFileA: expected failure\n"); ok(GetLastError() == ERROR_SHARING_VIOLATION ||
ok(GetLastError() == ERROR_SHARING_VIOLATION || broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */ "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
"MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
}
CloseHandle(hmapfile); CloseHandle(hmapfile);
CloseHandle(hfile); CloseHandle(hfile);
...@@ -1934,12 +1932,10 @@ static void test_MoveFileA(void) ...@@ -1934,12 +1932,10 @@ static void test_MoveFileA(void)
ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError()); ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
ret = MoveFileA(source, dest); ret = MoveFileA(source, dest);
todo_wine { ok(!ret, "MoveFileA: expected failure\n");
ok(!ret, "MoveFileA: expected failure\n"); ok(GetLastError() == ERROR_SHARING_VIOLATION ||
ok(GetLastError() == ERROR_SHARING_VIOLATION || broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */ "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
"MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
}
CloseHandle(hmapfile); CloseHandle(hmapfile);
CloseHandle(hfile); CloseHandle(hfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment