Przeglądaj źródła

Return STATUS_ACCESS_DENIED when writing to file that was opened for reading and vice versa

Tal Aloni 8 lat temu
rodzic
commit
ee55b59a2f
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      SMBLibrary/Server/Helpers/NTFileSystemHelper.cs

+ 2 - 2
SMBLibrary/Server/Helpers/NTFileSystemHelper.cs

@@ -274,7 +274,7 @@ namespace SMBLibrary.Server
             }
             else // File
             {
-                if (stream == null)
+                if (stream == null || !stream.CanRead)
                 {
                     state.LogToServer(Severity.Debug, "ReadFile: Cannot read '{0}', Invalid Operation.", openFilePath);
                     return NTStatus.STATUS_ACCESS_DENIED;
@@ -335,7 +335,7 @@ namespace SMBLibrary.Server
             }
             else // File
             {
-                if (stream == null)
+                if (stream == null || !stream.CanWrite)
                 {
                     state.LogToServer(Severity.Debug, "WriteFile: Cannot write '{0}'. Invalid Operation.", openFilePath);
                     return NTStatus.STATUS_ACCESS_DENIED;