Qian Hong : server: Forbid deleting files with an open mapping.

Alexandre Julliard julliard at winehq.org
Mon Jun 28 16:49:34 CDT 2021


Module: wine
Branch: master
Commit: 73d0bb77409b1a27fd25169516759cf0bd9d3d9a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=73d0bb77409b1a27fd25169516759cf0bd9d3d9a

Author: Qian Hong <qhong at codeweavers.com>
Date:   Fri Jun 25 00:28:49 2021 -0500

server: Forbid deleting files with an open mapping.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/file.c |  8 ++++----
 server/fd.c             | 11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 5d234114fd5..19ae5f2ac21 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -3329,14 +3329,14 @@ todo_wine
 
     fdi.DoDeleteFile = TRUE;
     res = pNtSetInformationFile( handle, &io, &fdi, sizeof(fdi), FileDispositionInformation );
-    todo_wine ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res );
+    ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res );
     res = GetFileAttributesA( buffer );
     ok( res != INVALID_FILE_ATTRIBUTES, "expected file to exist\n" );
 
     CloseHandle( mapping );
     CloseHandle( handle );
     res = DeleteFileA( buffer );
-    todo_wine ok( res, "got error %u\n", GetLastError() );
+    ok( res, "got error %u\n", GetLastError() );
 
     GetTempFileNameA( tmp_path, "dis", 0, buffer );
     handle = CreateFileA( buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
@@ -3373,14 +3373,14 @@ todo_wine
 
     fdi.DoDeleteFile = TRUE;
     res = pNtSetInformationFile( handle, &io, &fdi, sizeof(fdi), FileDispositionInformation );
-    todo_wine ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res );
+    ok( res == STATUS_CANNOT_DELETE, "got %#x\n", res );
     res = GetFileAttributesA( buffer );
     ok( res != INVALID_FILE_ATTRIBUTES, "expected file to exist\n" );
 
     UnmapViewOfFile( view );
     CloseHandle( handle );
     res = DeleteFileA( buffer );
-    todo_wine ok( res, "got error %u\n", GetLastError() );
+    ok( res, "got error %u\n", GetLastError() );
 
     GetTempFileNameA( tmp_path, "dis", 0, buffer );
     handle = CreateFileA( buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
diff --git a/server/fd.c b/server/fd.c
index bfa2805d82b..e326354d127 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2452,6 +2452,17 @@ static void set_fd_disposition( struct fd *fd, int unlink )
 
     if (unlink)
     {
+        struct fd *fd_ptr;
+
+        LIST_FOR_EACH_ENTRY( fd_ptr, &fd->inode->open, struct fd, inode_entry )
+        {
+            if (fd_ptr->access & FILE_MAPPING_ACCESS)
+            {
+                set_error( STATUS_CANNOT_DELETE );
+                return;
+            }
+        }
+
         if (fstat( fd->unix_fd, &st ) == -1)
         {
             file_set_error();




More information about the wine-cvs mailing list