Browse Source

SMB1FileStoreHelper: Delete / Rename: The status of SetFileInformation should be returned regardless of the status of CloseFile

Tal Aloni 7 years ago
parent
commit
2457d2c246
1 changed files with 16 additions and 16 deletions
  1. 16 16
      SMBLibrary/Server/SMB1/SMB1FileStoreHelper.cs

+ 16 - 16
SMBLibrary/Server/SMB1/SMB1FileStoreHelper.cs

@@ -41,20 +41,20 @@ namespace SMBLibrary.Server.SMB1
         {
         {
             object handle;
             object handle;
             FileStatus fileStatus;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, DirectoryAccessMask.DELETE, 0, 0, CreateDisposition.FILE_OPEN, createOptions, securityContext);
-            if (openStatus != NTStatus.STATUS_SUCCESS)
+            NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, DirectoryAccessMask.DELETE, 0, 0, CreateDisposition.FILE_OPEN, createOptions, securityContext);
+            if (status != NTStatus.STATUS_SUCCESS)
             {
             {
-                return openStatus;
+                return status;
             }
             }
             FileDispositionInformation fileDispositionInfo = new FileDispositionInformation();
             FileDispositionInformation fileDispositionInfo = new FileDispositionInformation();
             fileDispositionInfo.DeletePending = true;
             fileDispositionInfo.DeletePending = true;
-            NTStatus setStatus = fileStore.SetFileInformation(handle, fileDispositionInfo);
-            if (setStatus != NTStatus.STATUS_SUCCESS)
+            status = fileStore.SetFileInformation(handle, fileDispositionInfo);
+            if (status != NTStatus.STATUS_SUCCESS)
             {
             {
-                return setStatus;
+                return status;
             }
             }
-            NTStatus closeStatus = fileStore.CloseFile(handle);
-            return closeStatus;
+            fileStore.CloseFile(handle);
+            return status;
         }
         }
 
 
         public static NTStatus Rename(INTFileStore fileStore, string oldName, string newName, SMBFileAttributes searchAttributes, SecurityContext securityContext)
         public static NTStatus Rename(INTFileStore fileStore, string oldName, string newName, SMBFileAttributes searchAttributes, SecurityContext securityContext)
@@ -68,21 +68,21 @@ namespace SMBLibrary.Server.SMB1
             {
             {
                 createOptions = CreateOptions.FILE_NON_DIRECTORY_FILE;
                 createOptions = CreateOptions.FILE_NON_DIRECTORY_FILE;
             }
             }
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, oldName, DirectoryAccessMask.DELETE, 0, 0, CreateDisposition.FILE_OPEN, createOptions, securityContext);
-            if (openStatus != NTStatus.STATUS_SUCCESS)
+            NTStatus status = fileStore.CreateFile(out handle, out fileStatus, oldName, DirectoryAccessMask.DELETE, 0, 0, CreateDisposition.FILE_OPEN, createOptions, securityContext);
+            if (status != NTStatus.STATUS_SUCCESS)
             {
             {
-                return openStatus;
+                return status;
             }
             }
             FileRenameInformationType2 renameInfo = new FileRenameInformationType2();
             FileRenameInformationType2 renameInfo = new FileRenameInformationType2();
             renameInfo.ReplaceIfExists = false;
             renameInfo.ReplaceIfExists = false;
             renameInfo.FileName = newName;
             renameInfo.FileName = newName;
-            NTStatus setStatus = fileStore.SetFileInformation(handle, renameInfo);
-            if (setStatus != NTStatus.STATUS_SUCCESS)
+            status = fileStore.SetFileInformation(handle, renameInfo);
+            if (status != NTStatus.STATUS_SUCCESS)
             {
             {
-                return setStatus;
+                return status;
             }
             }
-            NTStatus closeStatus = fileStore.CloseFile(handle);
-            return closeStatus;
+            fileStore.CloseFile(handle);
+            return status;
         }
         }
 
 
         public static NTStatus CheckDirectory(INTFileStore fileStore, string path, SecurityContext securityContext)
         public static NTStatus CheckDirectory(INTFileStore fileStore, string path, SecurityContext securityContext)